Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/327.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/asp.net/33.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 当TextMode=”时,在asp.net文本框中显示预定义的*****”;密码";_C#_Asp.net_Textbox_Passwords - Fatal编程技术网

C# 当TextMode=”时,在asp.net文本框中显示预定义的*****”;密码";

C# 当TextMode=”时,在asp.net文本框中显示预定义的*****”;密码";,c#,asp.net,textbox,passwords,C#,Asp.net,Textbox,Passwords,为文本属性赋值后,带有TextMode=“Password”的文本框将为空 如何设置密码文本框的预定义密码 此外,我还想将此jQuery代码用于我的文本框: function onclickOfPassword(This) { if (This.value == 'Password') { This.value = ''; } } function onblurOfPassword(This) { if (This.value == '') {

为文本属性赋值后,带有TextMode=“Password”的文本框将为空

如何设置密码文本框的预定义密码

此外,我还想将此jQuery代码用于我的文本框:

function onclickOfPassword(This) {
    if (This.value == 'Password') {
        This.value = '';
    }
}

function onblurOfPassword(This) {
    if (This.value == '') {
        This.value = 'Password';
    }
}

您可以这样做……使用jquery

通过使用下面的函数,我们可以显示和隐藏两个不同的输入。您需要将一个设置为ID Password,另一个设置为ID PasswordDummy,对于没有javascript的客户端,最好将PasswordDummy设置为最初显示:none

$(‘input’).each(function() 
 {
     if (this.id == ‘Password’) {

       // Handle Password differently – it only gets an onblur, in which it gies invisible and activates the PasswordDummy if it is empty
      // if its blank, make it invisible and Dummy visible

  if (this.value == ”) 
  {
     $(this).hide();
     $(“#PasswordDummy”).show();
   }

  else 
  {
     $(this).show();
     $(“#PasswordDummy”).hide();
  }

$(this).blur(function()
{
   if (this.value == ”) {
   $(this).hide();
   $(“#PasswordDummy”).show();
}
else 
{
    $(this).show();
     $(“#PasswordDummy”).hide();
}
});
}

else if (this.id == ‘PasswordDummy’) {

// Handle Password Dummy differently

this.value = $(this).attr(‘title’);
$(this).addClass(‘text-label’);

$(this).focus(function()
{
  $(this).hide();
  $(“#Password”).show();
  $(“#Password”).focus(); });
}
else if ($(this).attr(‘title’) != undefined)
{
 if (this.value == ”) 
 {
   this.value = $(this).attr(‘title’);
   $(this).addClass(‘text-label’);
  }
$(this).focus(function()
{
   if (this.value == $(this).attr(‘title’)) {
   this.value = ”;
   $(this).removeClass(‘text-label’);
}});

$(this).blur(function() 
{
   if (this.value == ”) {
   this.value = $(this).attr(‘title’);
   $(this).addClass(‘text-label’);
}});
}
});

我没有-1,但我标记为的副本-