欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

詳解Asp.Net母版頁元素ID不一致的體現(xiàn)

 更新時(shí)間:2018年11月14日 09:25:31   作者:森大科技  
由于總體排版和設(shè)計(jì)的需要,我們往往創(chuàng)建母版頁來實(shí)現(xiàn)整個(gè)網(wǎng)站的統(tǒng)一性,這篇文章主要介紹了詳解Asp.Net母版頁元素ID不一致的體現(xiàn),感興趣的小伙伴們可以參考一下

本文介紹了Asp.Net母版頁元素ID不一致的體現(xiàn),分享給大家,具體如下;

<%@ Page Language="C#" MasterPageFile="~/MasterPage.master" Theme="style" AutoEventWireup="true"
   CodeFile="r_Balance.aspx.cs" Inherits="Report_r_Balance" %>

<asp:Content ID="content" ContentPlaceHolderID="MainContent" runat="server">

 

   <form id="form1" runat="server">
     <div>
       <table cellspacing="0" cellpadding="0" border="0">
         <tbody>
           <tr>
             <td>
               <asp:Label ID="lbPagename" runat="server" SkinID=" " Text="余額統(tǒng)計(jì)"></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>
       <!--結(jié)束功能條-->
       <table border="1" style="font: 宋體; font-size: 12px;">
         <tr>
                   <td style="width: 256px; height: 15px;">
             卡號(hào)*</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: 宋體; width: 180px;"
            >
             <asp:ImageButton ID="nSearch" runat="server" AlternateText="查詢" ImageAlign="Middle"
               ImageUrl="~/images/go.gif" ="nSearch_Click" />
           </td>
         </tr>
       </table>

....

生成的HTML代碼:

  <form name="aspnetForm" method="post" action="r_Balance.aspx" id="aspnetForm">

<table cellspacing="0" cellpadding="0" border="0">
         <tbody>
           <tr>
             <td>
               <span id="ctl00_MainContent_lbPagename" style="display:inline-block;color:#F2F3F9;border-style:None;font-family:宋體;font-size:13px;height:22px;">余額統(tǒng)計(jì)</span>
             </td>
           </tr>
           <tr>
             <td>
               <input type="image" name="ctl00$MainContent$btnPrint" id="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" id="ctl00_MainContent_btnExport" src="../App_Themes/style/images/b_export.jpg" style="border-style:Ridge;border-width:0px;" />
             </td>
           </tr>
         </tbody>
       </table>
       <!--結(jié)束功能條-->
       <table border="1" style="font: 宋體; font-size: 12px;">
         <tr>

           <td style="width: 256px; height: 15px;">
             卡號(hào)*</td>
           <td colspan="1" style="width: 233px; height: 15px">
             <input name="ctl00$MainContent$txtc_printno" type="text" id="ctl00_MainContent_txtc_printno" style="width:120px;height:16px;font-size:12px;font-family:宋體;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: 宋體; width: 180px;"
            >
             <input type="image" name="ctl00$MainContent$nSearch" id="ctl00_MainContent_nSearch" src="../images/go.gif" alt="查詢" ="return nselect();" style="border-width:0px;" />
           </td>
         </tr>
       </table>

注意:

1.源文件控件和元素ID和生成HTML文件的ID不一致。在生成的HTML中原ASP控件ID加了ctl00_MainContent_前綴,其他元素加了ctl00$MainContent$前綴。原變form1為aspnetForm這是因?yàn)閍spx頁面的控件是母板頁的ContentPlaceHolder
控件下的子控件,所以控件ID會(huì)變

2.<system.Web><xhtmlConformance mode="Transitional|Legacy|Strict" />在其中選擇 Transitional、Strict則產(chǎn)生自動(dòng)前綴。ctl00.選擇 Legacy|則產(chǎn)生自動(dòng)前綴_ctl0.

3.后臺(tái)Request.Form["txtc_name"]鍵值需要改變,必須變?yōu)镽equest.Form["ctl00$MainContent$txtc_name"]才能收到頁面輸入值

4.至于為什么,只能說這是.NET機(jī)制問題。。。

以上就是本文的全部內(nèi)容,希望對大家的學(xué)習(xí)有所幫助,也希望大家多多支持腳本之家。

相關(guān)文章

最新評論