Let's keep looking at <%=%>.
This is used to transfer values from the background page to the foreground page, which is used in the foreground to invoke the background variables or parameters, the foreground code is as follows:
<form id="Form1" runat="server"> <div> <%=name%> </div> </form>
The background code is as follows:
Public Partial class index:system.web.ui.page{ public String name; protected void Page_Load (object sender, EventArgs e) { name"haha" ; }}
Next, let's take a look at <%#%>
This is a data control binding display used, with a variety of display methods
1.<%# Eval ("field queried")%> for example
<asp:datalist id="DataList1"runat="Server"Datasourceid="SqlDataSource1"> <ItemTemplate>_id:<asp:label id="_idlabel"runat="Server"text='<%# Eval ("_id")%>'/> <br/>_name:<asp:label id="_namelabel"runat="Server"text='<%# Eval ("_name")%>'/> <br/>_sex:<asp:label id="_sexlabel"runat="Server"text='<%# Eval ("_sex")%>'/> <br/>_tel:<asp:label id="_tellabel"runat="Server"text='<%# Eval ("_tel")%>'/> <br/><br/> </ItemTemplate> </asp:DataList>
2,<% #Bind ("")%> data source bound control of the FormView data display and binding, the code is as follows
<asp:formview id="FormView1"runat="Server"Datasourceid="SqlDataSource1"> <EditItemTemplate>_id:<asp:label id="_idlabel1"runat="Server"text='<%# Eval ("_id")%>'/> <br/>_name:<asp:textbox id="_nametextbox"runat="Server"text='<%# Bind ("_name")%>'/> <br/>_sex:<asp:checkbox id="_sexcheckbox"runat="Server"Checked='<%# Bind ("_sex")%>'/> <br/>_tel:<asp:textbox id="_teltextbox"runat="Server"text='<%# Bind ("_tel")%>'/> <br/> <asp:linkbutton id="UpdateButton"runat="Server"causesvalidation="True"CommandName="Update"text="Update"/> <asp:linkbutton id="Updatecancelbutton"runat="Server"CausesValidation="False"Commandname="Cancel"text="Cancel"/> </EditItemTemplate> <InsertItemTemplate>_name:<asp:textbox id="_nametextbox"runat="Server"text='<%# Bind ("_name")%>'/> <br/>_sex:<asp:checkbox id="_sexcheckbox"runat="Server"Checked='<%# Bind ("_sex")%>'/> <br/>_tel:<asp:textbox id="_teltextbox"runat="Server"text='<%# Bind ("_tel")%>'/> <br/> <asp:linkbutton id="Insertbutton"runat="Server"causesvalidation="True"CommandName="Insert"text="Insert"/> <asp:linkbutton id="Insertcancelbutton"runat="Server"CausesValidation="False"Commandname="Cancel"text="Cancel"/> </InsertItemTemplate> <ItemTemplate>_id:<asp:label id="_idlabel"runat="Server"text='<%# Eval ("_id")%>'/> <br/>_name:<asp:label id="_namelabel"runat="Server"text='<%# Bind ("_name")%>'/> <br/>_sex:<asp:checkbox id="_sexcheckbox"runat="Server"Checked='<%# Bind ("_sex")%>'Enabled="false"/> <br/>_tel:<asp:label id="_tellabel"runat="Server"text='<%# Bind ("_tel")%>'/> <br/> </ItemTemplate> </asp:FormView>
Finally, let's take a look at the rarely used <%$%>
This code is rarely seen, but can be used when using multi-language transformations, that is, you must first establish global and local resources, and then configure the following code in the configuration file, and then invoke the configuration file. The code is as follows
Configuration file Code
configuration> <appSettings> <add key= "Connect" value= "Hello"/> </appSettings> <system.web> <compilation debug= "false" targetframework= "4.0"/> </system.web> </configuration>
To configure the calling code
<form id="Form1"runat="Server"> <div> <%--<asp:label id="Label1"runat="Server"text="<%$ resources:age%>"></asp:Label>--%> <asp:literal id="Literal1"runat="Server"text="<%$ resources:default.aspx,name%>"/> <asp:literal id="Literal2"runat="Server"text="<%$ resources:default.aspx,age%>"/> <asp:label id="heh"runat="Server"text="<%$ appsettings:connect%>"></asp:Label> </div>
All code Download