自己编写一个用户控件、如 Member_Login.ascx
<table border="0" cellpadding="0" cellspacing="0" runat="server" id="Table_NoLogin">
<tr>
<td >
<span class="login">会员:用户名
<asp:TextBox ID="LoginId" CssClass="input1" runat="server" Columns="8" MaxLength="25" ></asp:TextBox>
密码
<asp:TextBox ID="LoginPwd" CssClass="input1" runat="server" Columns="8" MaxLength="50" ></asp:TextBox>
<asp:Label Text=" 验证码" runat="server" id="Code_Text"></asp:Label>
<asp:TextBox ID="Code_Input" CssClass="input1" runat="server" Columns="8" MaxLength="50" ></asp:TextBox>
</span>
</td>
<td valign="bottom" >
<img src="../ValidateCode.aspx?S=0" id="Code_Img" runat="server" alt="" />
</td>
<td valign="bottom" >
<input id="Code_New" type="button" class="login_button1" value="看不清" runat="server" onclick="document.getElementById('<%=Code_Img.ClientID %>').src = '../ValidateCode.aspx??S=0&flag=' + Math.random()" />
<asp:Button ID="Btn_Login" runat="server" PostBackUrl="Login.aspx" Text="登 录" CssClass="login_button2" />
<input name="FindPwd" type="button" class="login_button3" value="找回密码" onclick="" />
<input id="Btn_Reg" type="button" class="login_button2" value="注 册" runat="server" />
</td>
</tr>
</table>然后页面上引用 <Member:MemberLogin ID="MSL" runat="server" />这样 在最后生成的页面上 就变成
<span class="login">会员:用户名
<input name="MSL$LoginId" type="text" maxlength="25" size="8" id="MSL_LoginId" class="input1" />
密码
<input name="MSL$LoginPwd" type="text" maxlength="50" size="8" id="MSL_LoginPwd" class="input1" />
<span id="MSL_Code_Text"> 验证码</span>
<input name="MSL$Code_Input" type="text" maxlength="50" size="8" id="MSL_Code_Input" class="input1" />
</span>就是把我的控件的 id 和name名字都改了 我在自定义控件里面 还需要写一些js函数 就不会起作用了 找不到id name值了
而 <Member:MemberLogin ID="MSL" runat="server" />
这个id 是可以随便写的 我在控件里面 使用document.getElementById('<%=Code_Img.ClientID %> 他给我生成的是 document.getElementById('<%=Code_Img.ClientID %>
我不想让Id name改变
因为<asp:Button ID="Btn_Login" runat="server" PostBackUrl="Login.aspx" Text="登 录" CssClass="login_button2" />
是要传递到另外一个页面进行提交判断的 在那个页面 我没法是要request.form[""] 这里控件的名字 不好确定啊
请问大家 我该怎么做
谢谢大家了 着急啊!
<table border="0" cellpadding="0" cellspacing="0" runat="server" id="Table_NoLogin">
<tr>
<td >
<span class="login">会员:用户名
<asp:TextBox ID="LoginId" CssClass="input1" runat="server" Columns="8" MaxLength="25" ></asp:TextBox>
密码
<asp:TextBox ID="LoginPwd" CssClass="input1" runat="server" Columns="8" MaxLength="50" ></asp:TextBox>
<asp:Label Text=" 验证码" runat="server" id="Code_Text"></asp:Label>
<asp:TextBox ID="Code_Input" CssClass="input1" runat="server" Columns="8" MaxLength="50" ></asp:TextBox>
</span>
</td>
<td valign="bottom" >
<img src="../ValidateCode.aspx?S=0" id="Code_Img" runat="server" alt="" />
</td>
<td valign="bottom" >
<input id="Code_New" type="button" class="login_button1" value="看不清" runat="server" onclick="document.getElementById('<%=Code_Img.ClientID %>').src = '../ValidateCode.aspx??S=0&flag=' + Math.random()" />
<asp:Button ID="Btn_Login" runat="server" PostBackUrl="Login.aspx" Text="登 录" CssClass="login_button2" />
<input name="FindPwd" type="button" class="login_button3" value="找回密码" onclick="" />
<input id="Btn_Reg" type="button" class="login_button2" value="注 册" runat="server" />
</td>
</tr>
</table>然后页面上引用 <Member:MemberLogin ID="MSL" runat="server" />这样 在最后生成的页面上 就变成
<span class="login">会员:用户名
<input name="MSL$LoginId" type="text" maxlength="25" size="8" id="MSL_LoginId" class="input1" />
密码
<input name="MSL$LoginPwd" type="text" maxlength="50" size="8" id="MSL_LoginPwd" class="input1" />
<span id="MSL_Code_Text"> 验证码</span>
<input name="MSL$Code_Input" type="text" maxlength="50" size="8" id="MSL_Code_Input" class="input1" />
</span>就是把我的控件的 id 和name名字都改了 我在自定义控件里面 还需要写一些js函数 就不会起作用了 找不到id name值了
而 <Member:MemberLogin ID="MSL" runat="server" />
这个id 是可以随便写的 我在控件里面 使用document.getElementById('<%=Code_Img.ClientID %> 他给我生成的是 document.getElementById('<%=Code_Img.ClientID %>
我不想让Id name改变
因为<asp:Button ID="Btn_Login" runat="server" PostBackUrl="Login.aspx" Text="登 录" CssClass="login_button2" />
是要传递到另外一个页面进行提交判断的 在那个页面 我没法是要request.form[""] 这里控件的名字 不好确定啊
请问大家 我该怎么做
谢谢大家了 着急啊!
解决方案 »
免费领取超大流量手机卡,每月29元包185G流量+100分钟通话, 中国电信官方发货