这样用JS怎么不行啊?
我在cs程序里添加了onclick事件:
this.btnEdit.Attributes.Add( "OnClick ", "return MailOperate() ");
然后ascx页面引用:
<script language= "javascript " type= "text/javascript " src= "../../Js/SystemParameter.js "> </script>
SystemParameter.js里的代码为:
function MailOperate()
{
document.getElementById( " <%=lblOldPwd.ClientID %> ").style.display = "block ";
document.getElementById( " <%=lblNewPwd.ClientID %> ").style.display = "block ";
document.getElementById( " <%=lblNewPwdAgain.ClientID %> ").style.display = "block ";
document.getElementById( " <%=txtNewPwd.ClientID %> ").style.display = "block ";
document.getElementById( " <%=txtNewPwdAlagin.ClientID %> ").style.display = "block ";
var newpwd = document.getElementById( " <%=txtNewPwd.ClientID %> ");
var alaginpwd = document.getElementById( " <%=txtNewPwdAlagin.ClientID %> ");
var servername = " <%=txtServerName.ClientID %> ";
var txtServerName = document.getElementById(servername);
var smtpname = " <%=txtSMTPName.ClientID %> ";
var txtSMTPName = document.getElementById(smtpname);
var smtppwd = " <%=txtSMTPPWD.ClientID %> ";
var txtSMTPPWD = document.getElementById(smtppwd);
var sender = " <%=txtSender.ClientID %> ";
var txtSender = document.getElementById(sender);
var edit = " <%=btnEdit.ClientID %> ";
var btnEdit = document.getElementById(edit);
var message = " <%=lblMessage.ClientID %> ";
var lblMessage = document.getElementById(message);
if (txtServerName.style.borderWidth == "0px ")
{
txtServerName.style.borderWidth = 2;
txtServerName.readOnly = " ";
txtSMTPName.style.borderWidth = 2;
txtSMTPName.readOnly = " ";