因为txtPassword的TextMode="Password",不能直接赋值
所有就用了下面的这段代码,可是也没有用,请高手帮忙:
String hiddenName = "MyHiddenField";
String hiddenValue = "111"; String csname = "ConcatScript";
Type cstype = this.GetType(); ClientScriptManager cs = Page.ClientScript;
cs.RegisterHiddenField(hiddenName, hiddenValue); if (!cs.IsStartupScriptRegistered(cstype, csname))
{
System.Text.StringBuilder cstext = new StringBuilder();
cstext.Append("<script type=text/javascript> function DoClick() {");
cstext.Append("document.getElementById('txtPassword').value='" + hiddenValue + "';");
cstext.Append("form1.txtRePassword.value='" + hiddenValue + "';} </");
cstext.Append("script>");
cs.RegisterStartupScript(cstype, csname, cstext.ToString(), false);
}
所有就用了下面的这段代码,可是也没有用,请高手帮忙:
String hiddenName = "MyHiddenField";
String hiddenValue = "111"; String csname = "ConcatScript";
Type cstype = this.GetType(); ClientScriptManager cs = Page.ClientScript;
cs.RegisterHiddenField(hiddenName, hiddenValue); if (!cs.IsStartupScriptRegistered(cstype, csname))
{
System.Text.StringBuilder cstext = new StringBuilder();
cstext.Append("<script type=text/javascript> function DoClick() {");
cstext.Append("document.getElementById('txtPassword').value='" + hiddenValue + "';");
cstext.Append("form1.txtRePassword.value='" + hiddenValue + "';} </");
cstext.Append("script>");
cs.RegisterStartupScript(cstype, csname, cstext.ToString(), false);
}
if (!cs.IsStartupScriptRegistered(cstype, csname))
{
System.Text.StringBuilder cstext = new StringBuilder();
cstext.Append("<script type=text/javascript> function DoClick() {");
cstext.Append("document.getElementById('txtPassword').value=document.getElementById('hf1').value;");
cstext.Append("}</script>");
cs.RegisterStartupScript(cstype, csname, cstext.ToString(), false);
}
大概这样了,有些错误自己改一下吧,因为是根据你的代码来写的但是最好把这样数据放在服务器方,放在一个viewstate中或session中,写值的时候判断一下,这些东西中是不是空,如果是空拿控件中的值,不为空拿session中