We often want to browse the category information on the home page. in C/S mode, we often use the tab paging method, and then place different information into different tab pages, then, you can click the tab to view the content on different pages. We can use the IFRAME of a webpage to implement this function. First, we can create a main webform1 and put two buttons on it to simulate the tab (in the future, we can also use Photoshop to create more refined tabs ), create two subforms, webform2 and webform3. When the button is pressed, switch the src attribute of IFRAME to display different subpages. The Code is as follows:
Webform1.aspx
<% @ Page Language = "C #" codebehind = "webform1.aspx. cs" autoeventwireup = "false" inherits = "iframetest. webform1" %>
<! Doctype HTML public "-// W3C // dtd html 4.0 transitional // en">
<HTML>
<Head>
<Title> webform1 </title>
<Meta content = "Microsoft Visual Studio. NET 7.1" name = "generator">
<Meta content = "C #" name = "code_language">
<Meta content = "JavaScript" name = "vs_defaultclientscript">
<Meta content = "http://schemas.microsoft.com/intellisense/ie5" name = "vs_targetschema">
<Style>. AAA {
Border-top-style: none; border-right-style: none; border-left-style: none; Background-color: # ffcc33; border-bottom-style: None
}
. BBB {
Border-top-style: none; border-right-style: none; border-left-style: none; Background-color: #99 ffcc; border-bottom-style: None
}
</Style>
</Head>
<Body ms_positioning = "gridlayout">
<Form ID = "form1" method = "Post" runat = "server">
<Asp: button id = "button1" style = "Z-INDEX: 101; left: 16px; position: absolute; top: 24px" runat = "server"
TEXT = "button" cssclass = "AAA"> </ASP: button>
<Asp: button id = "button2" style = "Z-INDEX: 102; left: 72px; position: absolute; top: 24px" runat = "server"
TEXT = "button" cssclass = "BBB"> </ASP: button>
<IFRAME id = "iframe1" style = "border-Right: 0px solid; border-top: 0px solid; Z-INDEX: 103; left: 16px; border-left: 0px solid; width: 648px; border-bottom: 0px solid; position: absolute; top: 40px; Height: 288px"
Runat = "server"> </iframe>
</Form>
</Body>
</Html> |
Webform1.aspx. CS
|
.
.
.
Private void button#click (Object sender, system. eventargs E)
{
Iframe1.attributes. Add ("src", "webform2.aspx ");
}
Private void button2_click (Object sender, system. eventargs E)
{
Iframe1.attributes. Add ("src", "webform3.aspx ");
} |