ASP.NET中使用多个runat=server form(转)
代码如下:
2FormExample.aspx
<%@ Page language="c#" Codebehind="2FormExample.cs" AutoEventWireup="false"
Inherits="_3leaf_app.C2FormExample" %>
<html><head>
<meta name=vs_targetSchema content="HTML 4.0">
<meta name="GENERATOR" Content="Microsoft Visual Studio 7.0">
<meta name="CODE_LANGUAGE" Content="C#"></head>
<body>
<form method="post" runat="server" ID=Form1>
<p>Lookup by
<asp:RadioButton id=RadioButton1 runat="server" Text="First Name" AutoPostBack="True" groupname=g1
checked=True></asp:RadioButton>
<asp:RadioButton id=RadioButton2 runat="server" Text="Last Name" AutoPostBack="True"
groupname=g1></asp:RadioButton></p>
<p></p>
<p>
<asp:Panel id=Panel1 runat="server" visible=True>
First Name :
<asp:TextBox id=TextBox1 runat="server"></asp:TextBox>
<asp:RequiredFieldValidator id=RequiredFieldValidator1 runat="server" ErrorMessage="*"
ControlToValidate="TextBox1"></asp:RequiredFieldValidator>
<asp:Button id=Button1 runat="server" Text="Submit"></asp:Button>
</asp:Panel>
<asp:Panel id=Panel2 runat="server" visible=False>
Last Name :
<asp:TextBox id=TextBox2 runat="server"></asp:TextBox>
<asp:RequiredFieldValidator id=RequiredFieldValidator2 runat="server" ErrorMessage="*"
ControlToValidate="TextBox2"></asp:RequiredFieldValidator>
<asp:Button id=Button2 runat="server" Text="Submit"></asp:Button>
</asp:Panel>
<p></p>
<p>
<asp:label id=Label1 runat="server"></asp:label>
</p>
</form>
</body></html>
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>
/// Summary description for C2FormExample.
/// </summary>
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();
}
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
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;
}
}
}
ASP.NET中使用多个runat=server form(转)相关推荐
- ASP.NET中使用多个runat=server form
作者:未知 ASP.NET 在同一个页面不支持多个 runat=server forms,要解决这个问题,可以把每个 form 放在一个单独的 panel 控件中,这样用户就可以简单地通过单选按钮在不 ...
- ASP.Net中利用CSS实现多界面两法
通过使页面动态加载不同CSS实现多界面 方法一: <%@page language="C#"%> <%@import namespace="System ...
- 在ASP.Net中两种利用CSS实现多界面的方法(转)
通过使页面动态加载不同CSS实现多界面 方法一: <%@page language="C#"%> <%@import namespace="System ...
- 类型“DropDownList”的控件“ContentPlaceHolder1_ddlDepartment”必须放在具有 runat=server 的窗体标记内。
小编今天在开发时运行出现报错黄页,图中提示信息为"类型"DropDownList"的控件"ContentPlaceHolder1_ddlDepartment&q ...
- ASP.NET中使用script runat=server
ASP.NET中使用<script runat="server"> 标签: asp.netserver服务器objectasp 2012-04-11 09:46 475 ...
- 在asp.net中为Web用户控件添加属性和事件
在90年代初,Microsoft为Web程序员提供的 Active Server Pages(ASP)革命性地改变了Web的编程.它可以利用十分易用的模型在Web服务器上动态生成HTML,并且很容易的 ...
- ASP.NET中WebForm组件CheckBoxList编程
作者:马金虎 来自:yesky CheckBox选择组件是一个程序中都经常的组件.在程序设计中使用到该组件,一般都不会只使用到一个,往往是以多个此类组件的形式出现的.在ASP.NET页面中如果要使用 ...
- 关于百度编辑器UEditor在asp.net中的使用方法!
为了完成自己想要的功能效果,在项目中使用到了百度编辑器,为了搞明白,苦心学习查资料搞了整整一天,总结一下. 在asp.net 的项目中目前我觉得有两种情况,一种是没有使用模板页的,一种是使用了模板页的 ...
- ASP.NET中随机数生成及应用
asp.net中随机数生成及应用 asp.net中随机数生成及应用 ------------------------------------------------------------------ ...
最新文章
- 阿里云中间件首席架构师李小平:云原生实践助力企业高效创新
- JavaScript中Map的应用及Map中的bug
- vue Mutation 必须是同步函数 为什么_Vue 开发必须知道的 36 个技巧「近1W字」
- windows文件路径大于MAX_PATH
- 优考试在线考试系统计算机,使用优考试在线考试系统解决企业员工考核评比
- 私人笔记 -- 将图片插入到指定的单元格位置,并设置图片的宽度和高度
- [BZOJ2440][中山市选2011]完全平方数(莫比乌斯函数,二分)
- word计算机排版怎么选,Word选择题选项对齐排版方法 查找替换工具搞定
- 并查集应用——PAT甲级2019春季
- 【心电信号】基于matlab心电图峰值检测【含Matlab源码 1548期】
- 三菱FX系列PLC-编程1
- 单片机原理与接口技术期末总复习
- 关于用LM2596做的DC-DC数控电源
- 解决-手机通过Charles连接代理无法上网,亲测可用
- Python3从搜狐国际新闻抓取---完整版
- 打砖块c语言算法,C语言打砖块游戏的原理!哪位高手指点一下,程序有!
- 蒙特卡罗模拟计算定积分(R)
- [转]这些道理不懂,你注定就是穷打工的命
- Docker入门教程 Part 1 基础概念 - 镜像、容器、仓库
- 男女老少皆宜的15种瘦身食物,著名人生保健专家撰写
热门文章
- error while loading shared libraries: libconfig.so.8
- 第一部分:基础知识(第一章)File | New | Project
- android 点滴积累
- 清空select下拉框的方法
- 《极客与团队》一说到底真正重要的还是代码本身
- JetBrains发布Toolbox 采用新的订阅模式
- 使用Axis,在webservice的服务器端如何取到客户端的IP地址
- 9-9 原生安装-1
- 计算机辅助建筑制图规范,房屋建筑制图统一标准 [附条文说明] GB/T50001-2017
- ftp服务器通常提供文件上传和,基于FTPClient的文件上传至Nginx服务器