这是用一个页面写下的代码!
 我想在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>

解决方案 »

  1.   

    用vs.net就放几个控件,然后在后台直接写代码,
    分不开的,你要分了也要在其中用protected声明你程序中用到的控件,很麻烦。
      

  2.   

    在Button的点击事件中编写代码 
    在 .cs文件中
      

  3.   

    那要实现上面的功能.aspx页面那里怎么写?
    .CS文件里要怎么写?
    帮写出我看一次行吗/?
      

  4.   

    在.cs文件中写代码,
    在页面上放几个控件,双击button控件就可以写代码了
      

  5.   

    html页面:
    <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>";
      

  6.   

    TO 楼上
    出现这样的错误。怎么回事?
    析器错误信息: 未能加载类型“WebApplication11.Global”。源错误: 
    行 1:  <%@ Application Codebehind="Global.asax.cs" Inherits="WebApplication11.Global" %> 
      

  7.   


     vikingleo(云风^NET)在帮我看看好吗?
      

  8.   

    ---行 1:  <%@ Application Codebehind="Global.asax.cs" Inherits="WebApplication11.Global" %>
    你在html页第一行加上<%@ Page language="c#" Codebehind="WebForm1.aspx.cs" AutoEventWireup="false" Inherits="WebApplication1.WebForm1" %>就可以了
    其中"WebForm1.aspx.cs" 是你页面生成的 cs文件名,"WebApplication1.WebForm1"是你的命名空间
      

  9.   

    加了呀。还是一样文件名我都没有改!.aspx代码:<%@ Page language="c#" Codebehind="WebForm1.aspx.cs" AutoEventWireup="false" Inherits="WebApplication11.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