This article introduces the inconsistency of element IDs of the master page. It is shared with you. The details are as follows;
<%@ Page Language="C#" MasterPageFile="~/" Theme="style" AutoEventWireup="true" CodeFile="r_Balance." Inherits="Report_r_Balance" %> <asp:Content ID="content" ContentPlaceHolderID="MainContent" runat="server"> <form runat="server"> <div> <table cellspacing="0" cellpadding="0" border="0"> <tbody> <tr> <td> <asp:Label ID="lbPagename" runat="server" SkinID=" " Text="Balance Statistics"></asp:Label> </td> </tr> <tr> <td> <asp:ImageButton ID="btnPrint" runat="server" SkinID="b_print" ="btnPrint_Click" /> <asp:ImageButton ID="btnExport" runat="server" SkinID="b_export" ="btnExport_Click" /> </td> </tr> </tbody> </table> <!--End function bar--> <table border="1" style="font: Song font; font-size: 12px;"> <tr> <td style="width: 256px; height: 15px;"> card number*</td> <td colspan="1" style="width: 233px; height: 15px"> <asp:TextBox ID="txtc_printno" runat="server"></asp:TextBox></td> <td colspan="1" style="height: 24px; font-size: 14px; font-family: Stick; width: 180px;" > <asp:ImageButton ID="nSearch" runat="server" AlternateText="Query" ImageAlign="Middle" ImageUrl="~/images/" ="nSearch_Click" /> </td> </tr> </table> ....
Generated HTML code:
<form name="aspnetForm" method="post" action="r_Balance.aspx" > <table cellspacing="0" cellpadding="0" border="0"> <tbody> <tr> <td> <span style="display:inline-block;color:#F2F3F9;border-style:None;font-family:Secure;font-size:13px;height:22px;">Balance statistics</span> </td> </tr> <tr> <td> <input type="image" name="ctl00$MainContent$btnPrint" src="../App_Themes/style/images/b_print.jpg" ="return np();" style="border-style:Ridge;border-width:0px;" /> <input type="image" name="ctl00$MainContent$btnExport" src="../App_Themes/style/images/b_export.jpg" style="border-style:Ridge;border-width:0px;" /> </td> </tr> </tbody> </table> <!--End function bar--> <table border="1" style="font: Song font; font-size: 12px;"> <tr> <td style="width: 256px; height: 15px;"> card number*</td> <td colspan="1" style="width: 233px; height: 15px"> <input name="ctl00$MainContent$txtc_printno" type="text" style="width:120px;height:16px;font-size:12px;font-family:Safety;color:DimGray;border-width:1px;border-style:Solid;border-color:#C4CAE6;background-color:White;" /></td> <td colspan="1" style="height: 24px; font-size: 14px; font-family: Stick; width: 180px;" > <input type="image" name="ctl00$MainContent$nSearch" src="../images/" alt="Query" ="return nselect();" style="border-width:0px;" /> </td> </tr> </table>
Notice:
1. The source file control and element ID are inconsistent with the ID of the generated HTML file. The generated HTML Central ASP control ID is prefixed with ctl00_MainContent_, and other elements are prefixed with ctl00$MainContent$. Original form1 is aspnetForm This is because the control of the aspx page is the ContentPlaceHolder of the motherboard page
The child control under the control, so the control ID will change
2.<><xhtmlConformance mode="Transitional|Legacy|Strict" />Select Transitional and Strict to generate automatic prefix. ctl00. Selecting Legacy| will generate the automatic prefix_ctl0.
3. The key value of the background ["txtc_name"] needs to be changed and must be changed to ["ctl00$MainContent$txtc_name"] to receive the page input value.
4. As for why, I can only say that this is a problem with the .NET mechanism. . .
The above is all the content of this article. I hope it will be helpful to everyone's study and I hope everyone will support me more.