Apply jquery easyui layout to Asp.net webform
Write layout according to the example in easyui document
Code :
<Body class = "easyui-layout">
<Div region = "North" border = "false" style = "height: 60px; Background: # b3dfda;"> North Region </div>
<Div region = "West" split = "true" Title = "West" style = "width: 150px; padding: 10px;"> West content </div>
<Div region = "East" split = "true" Title = "East" style = "width: 100px; padding: 10px;"> East Region </div>
<Div region = "South" border = "false" style = "height: 50px; Background: # a9facd; padding: 10px;"> south region </div>
<Div region = "center" Title = "Main title">
</Div>
</Body>
On a common HTML page, you can get a layout that is automatically adjusted according to the window size. However, an error occurs when it is placed in the webform of Asp.net (. NET 4:
<Body class = "easyui-layout">
<Form ID = "form1" runat = "server">
<Div region = "North" border = "false" style = "height: 60px; Background: # b3dfda;"> North Region </div>
<Div region = "West" split = "true" Title = "West" style = "width: 150px; padding: 10px;"> West content </div>
<Div region = "East" split = "true" Title = "East" style = "width: 100px; padding: 10px;"> East Region </div>
<Div region = "South" border = "false" style = "height: 50px; Background: # a9facd; padding: 10px;"> south region </div>
<Div region = "center" Title = "Main title">
</Div>
</Form>
</Body>
"Nodename is empty or not an object" is displayed during running"
The tracing debugging found that the divs defining the layout are not the direct sub-objects of the elements defined as "easyui-layout" by the class.
Modify the definition as follows:
<Form ID = "form1" runat = "server" class = "easyui-layout">
However, the layout cannot be displayed. Further research shows that the preceding form element does not define the absolute width. If you want to define the following, you can get the layout:
<Form ID = "form1" runat = "server" class = "easyui-layout"
Style = "width: 600px; Height: 400px;"> however, a fixed layout cannot be changed with the window size. The following code uses the resize event to add a script: <SCRIPT type = "text/JavaScript">
$ (Function (){
Windowresize ();
$ (Window). Resize (function (){
Windowresize ();
});
});
Function getwindowheight (){
Return $ (window). Height ();
}
Function get1_wwidth (){
Return $ (window). Width ();
}
Function windowresize (){
VaR width = get1_wwidth ();
VaR Height = getwindowheight ();
$ ('Form # form1 '). Width (width );
$ ('Form # form1 '). Height (height );
$ ('Form # form1 '). layout ();
}
</SCRIPT>
<Style type = "text/CSS">
Body
{
Padding: 0px;
Margin: 0px;
}
</Style>
</Head>
<Body>
<Form ID = "form1" runat = "server">
<Div region = "North" border = "false" style = "height: 60px; Background: # b3dfda;"> North Region </div>
<Div region = "West" split = "true" Title = "West" style = "width: 150px; padding: 10px;"> West content </div>
<Div region = "East" split = "true" Title = "East" style = "width: 100px; padding: 10px;"> East Region </div>
<Div region = "South" border = "false" style = "height: 50px; Background: # a9facd; padding: 10px;"> south region </div>
<Div region = "center" Title = "Main title">
</Div>
</Form>
</Body>
Originally, we wanted to write the resize event as an independent function, and then at $ (window ). resize (FN) is registered, but in this way, the function will only be executed once when the form is loaded for the first time. No matter how the window is changed, no event will be triggered, the function is directly written in resize (), so the form is not executed during loading! In IE, Firefox, and chorm, I had to write it like this!
The above Code gives you an adaptive window size layout!
PS: do not forget to add necessary JS files and CSS file references in