-
您的位置:首页 → 技术开发 → ASP技巧 → ASP.NET中使用多个runat=server form
ASP.NET中使用多个runat=server form
时间:2004/11/7 4:10:00来源:本站整理作者:蓝点我要评论(0)
-
ASP.NET 在同一个页面不支持多个 runat=server forms,要解决这个问题,可以把每个 form 放在一个单独的 panel 控件中,这样用户就可以简单地通过单选按钮在不同 panel 间切换。
代码如下:
2FormExample.aspx
<%@ Page language="c#" Codebehind="2FormExample.cs" AutoEventWireup="false"
Inherits="_3leaf_app.C2FormExample" %>
2FormExample.cs
namespace _3leaf_app
{
using System;
using System.Collections;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Web;
using System.Web.SessionState;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.HtmlControls;
///
/// Summary description for C2FormExample.
///
public class C2FormExample : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Button Button2;
protected System.Web.UI.WebControls.RequiredFieldValidator RequiredFieldValidator2;
protected System.Web.UI.WebControls.TextBox TextBox2;
protected System.Web.UI.WebControls.Button Button1;
protected System.Web.UI.WebControls.RequiredFieldValidator RequiredFieldValidator1;
protected System.Web.UI.WebControls.TextBox TextBox1;
protected System.Web.UI.WebControls.Label Label1;
protected System.Web.UI.WebControls.Panel Panel2;
protected System.Web.UI.WebControls.Panel Panel1;
protected System.Web.UI.WebControls.RadioButton RadioButton2;
protected System.Web.UI.WebControls.RadioButton RadioButton1;
public C2FormExample()
{
Page.Init += new System.EventHandler(Page_Init);
}
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
}
}
protected void Page_Init(object sender, EventArgs e)
{
//
// CODEGEN: This call is required by the ASP+ Windows Form Designer.
//
InitializeComponent();
}
///
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
///
private void InitializeComponent()
{
RadioButton1.CheckedChanged += new System.EventHandler (this.RadioButton1_CheckedChanged);
Button1.Click += new System.EventHandler (this.Button1_Click);
RadioButton2.CheckedChanged += new System.EventHandler (this.RadioButton2_CheckedChanged);
Button2.Click += new System.EventHandler (this.Button2_Click);
this.Load += new System.EventHandler (this.Page_Load);
}
public void Button2_Click (object sender, System.EventArgs e)
{
Label1.Text = "You want to search on last name";
}
public void Button1_Click (object sender, System.EventArgs e)
{
Label1.Text = "You want to search on first name";
}
public void RadioButton2_CheckedChanged (object sender, System.EventArgs e)
{
Panel1.Visible = false;
Panel2.Visible = true;
}
public void RadioButton1_CheckedChanged (object sender, System.EventArgs e)
{
Panel1.Visible = true;
Panel2.Visible = false;
}
}
}
相关阅读
Windows错误代码大全 Windows错误代码查询激活windows有什么用Mac QQ和Windows QQ聊天记录怎么合并 Mac QQ和Windows QQ聊天记录Windows 10自动更新怎么关闭 如何关闭Windows 10自动更新windows 10 rs4快速预览版17017下载错误问题Win10秋季创意者更新16291更新了什么 win10 16291更新内容windows10秋季创意者更新时间 windows10秋季创意者更新内容kb3150513补丁更新了什么 Windows 10补丁kb3150513是什么
-
热门文章
没有查询到任何记录。
最新文章
VB.NET 2005编写定时关
Jquery get/post下乱码解决方法 前台gbk gb如何使用数据绑定控件显示数据ASP脚本循环语句ASP怎么提速
人气排行
轻松解决"Server Application Error"和iis"一起学习DataGridView调整列宽用ASP随机生成文件名的函数Jquery get/post下乱码解决方法 前台gbk gbODBC Drivers错误80004005的解决办法返回UPDATE SQL语句所影响的行数的方法用Javascript隐藏超级链接的真实地址两个不同数据库表的分页显示解决方案
查看所有0条评论>>