A tips used in your work. For example, if you want to control the width and height of a <div> tag on the page, the data read by the database will automatically change.
On the page, add the ID and runat attributes to the <div> label,
<Div id = "div1" runat = "server">
In the backgroundCodeDeclare Variables
Protected system. Web. UI. htmlcontrols. htmlgenericcontrol div1;
Then you can play it as you like. For example, in a project, it is generally used as follows:
Private void binddetail ()
{
This. dgdetail. datasource = This. dsdetail. Tables [0];
This. dgdetail. databind ();
This. div1.style ["height"] = convert. tostring (this. dgdetail. Items. Count + 2) * 25-5 );
}
Use div1.style [] to set various attributes of the page tag div1.
Another common feature is the <tr> <TD> mark, which usually displays different data based on a specific status value.
On the page, add the ID and runat attributes:
<Tr Height = "18" id = "trbank" runat = "server">
<Tr Height = "18" id = "trmail;" runat = "server">
Declare variables in the background code
Protected system. Web. UI. htmlcontrols. htmltablerow trbank;
Protected system. Web. UI. htmlcontrols. htmltablerow trmail;
If (.....)
{// Display trbank data to hide trmail's
This. trbank. Style ["display"] = "";
This. trmail1.style ["display"] = "NONE ";
}
Else
{// Display trmail's
This. trbank. Style ["display"] = "NONE ";
This. trmail1.style ["display"] = "";
}
TIPS: page processing.
The variable declaration corresponding to an HTML page is usually completed after
Protected system. Web. UI. htmlcontrols.
In the pop-up automatic selection.