Apply jquery easyui layout to Asp.net webform

Source: Internet
Author: User
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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.