[ASP. NET] create a simple multi-page tab Function

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

}

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.