这是用一个页面写下的代码!
我想在VS。NET工具中写出来!应该怎么安排代码?
<% @ Page Language="C#" %>
<Script Language="C#" Runat="Server">
public void Button_Click(Object sender,EventArgs e)
{
string argName = ((Button)sender).CommandName;
string argArg = ((Button)sender).CommandArgument;
Label1.Text="您的选择是:<font color=red>"+argName+"</font>, 学分为:<font color=Blue>"+argArg+"</font>";
}
</script>
<html>
<head>
<title></title>
</head>
<body>
<H3>使用Button控件<Hr></H3>
<center>
<form runat="server">
<asp:Button id="Button1" CommandName="物理" CommandArgument="4学分" Text="功课一" runat="server" OnClick="Button_Click" /><br>
<asp:Button id="Button2" CommandName="数学" CommandArgument="5学分" Text="功课二" runat="server" OnClick="Button_Click" /><br>
<hr>
<asp:Label id="Label1" runat="server" />
</form>
</body>
</html>
我想在VS。NET工具中写出来!应该怎么安排代码?
<% @ Page Language="C#" %>
<Script Language="C#" Runat="Server">
public void Button_Click(Object sender,EventArgs e)
{
string argName = ((Button)sender).CommandName;
string argArg = ((Button)sender).CommandArgument;
Label1.Text="您的选择是:<font color=red>"+argName+"</font>, 学分为:<font color=Blue>"+argArg+"</font>";
}
</script>
<html>
<head>
<title></title>
</head>
<body>
<H3>使用Button控件<Hr></H3>
<center>
<form runat="server">
<asp:Button id="Button1" CommandName="物理" CommandArgument="4学分" Text="功课一" runat="server" OnClick="Button_Click" /><br>
<asp:Button id="Button2" CommandName="数学" CommandArgument="5学分" Text="功课二" runat="server" OnClick="Button_Click" /><br>
<hr>
<asp:Label id="Label1" runat="server" />
</form>
</body>
</html>
解决方案 »
- 验证码是叉叉,要刷新才能显示,怎么搞?
- 要个正则表达式,哪位正则达人来写写,先谢谢啦............................标题要长...要破坏河蟹社会................
- 从数据库中读取较长数据放在table中,怎样实现自动换行
- 出现错误Cannot convert type 'ASP.content_master' to 'System.Web.UI.WebControls.Content'
- 新手求救:如何正确连接数据库
- 熟悉三层结构的兄弟进来指点指点咱啊!
- 水晶报表的奇怪问题!!!!!!!!!!!!
- 求ASP.NET中登录按钮c#程序
- 100分问:DataGrid排序时如何获得当前排序列的列标题(Header Text)
- 如何用文件流方式读EXCEL文件
- 为什么按钮失效?急,在线等
- 关于添加COM组件问题,解决立刻结贴给分!!
分不开的,你要分了也要在其中用protected声明你程序中用到的控件,很麻烦。
在 .cs文件中
.CS文件里要怎么写?
帮写出我看一次行吗/?
在页面上放几个控件,双击button控件就可以写代码了
<html>
<head>
<title></title>
</head>
<body>
<H3>使用Button控件<Hr></H3>
<center>
<form runat="server">
<asp:Button id="Button1" CommandName="物理" CommandArgument="4学分" Text="功课一" runat="server"/><br>
<asp:Button id="Button2" CommandName="数学" CommandArgument="5学分" Text="功课二" runat="server"/><br>
<hr>
<asp:Literal id="Lit" runat="server" />
</form>
</body>
</html>cs 中 (在aspx页面点击Button) 进入Button_Click事件string argName = Button.CommandName;
string argArg = Button.CommandArgument;
Lit.Text="您的选择是:<font color=red>"+argName+"</font>, 学分为:<font color=Blue>"+argArg+"</font>";
出现这样的错误。怎么回事?
析器错误信息: 未能加载类型“WebApplication11.Global”。源错误:
行 1: <%@ Application Codebehind="Global.asax.cs" Inherits="WebApplication11.Global" %>
vikingleo(云风^NET)在帮我看看好吗?
你在html页第一行加上<%@ Page language="c#" Codebehind="WebForm1.aspx.cs" AutoEventWireup="false" Inherits="WebApplication1.WebForm1" %>就可以了
其中"WebForm1.aspx.cs" 是你页面生成的 cs文件名,"WebApplication1.WebForm1"是你的命名空间
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN" >
<HTML>
<HEAD>
<title></title>
</HEAD>
<body>
<H3>使用Button控件<Hr>
</H3>
<center>
<form runat="server" ID="Form1">
<asp:Button id="Button1" CommandName="物理" CommandArgument="4学分" Text="功课一" runat="server" /><br>
<asp:Button id="Button2" CommandName="数学" CommandArgument="5学分" Text="功课二" runat="server" /><br>
<hr>
<asp:Literal id="Lit" runat="server" />
</form>
</center>
</body>
</HTML>
.cs代码:
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;namespace WebApplication11
{
/// <summary>
/// WebForm1 的摘要说明。
/// </summary>
public class WebForm1 : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Button Button1;
protected System.Web.UI.WebControls.Button Button2;
protected System.Web.UI.WebControls.Literal Lit;
protected System.Web.UI.HtmlControls.HtmlForm Form1;
protected System.Web.UI.WebControls.Label Label1;
private void Page_Load(object sender, System.EventArgs e)
{
// 在此处放置用户代码以初始化页面
} #region Web 窗体设计器生成的代码
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: 该调用是 ASP.NET Web 窗体设计器所必需的。
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// 设计器支持所需的方法 - 不要使用代码编辑器修改
/// 此方法的内容。
/// </summary>
private void InitializeComponent()
{
this.Load += new System.EventHandler(this.Page_Load); }
#endregion private void Button_Click(object sender, System.EventArgs e)
{
string argName = Button.CommandName;
string argArg = Button.CommandArgument;
Lit.Text="您的选择是:<font color=red>"+argName+"</font>, 学分为:<font color=Blue>"+argArg+"</font>";
}
}
}提示就是就是这样的错误555555555555555555