<asp:Button CommandName="String" />
实现
IButtonControl..::.CommandName
备注
示例
<%@ Page Language="C#" AutoEventWireup="True" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html >
<head runat="server">
<title>Button CommandName Example</title>
<script runat="server">
void CommandBtn_Click(Object sender, CommandEventArgs e)
{
switch(e.CommandName)
{
case "Sort":
// Call the method to sort the list.
Sort_List((String)e.CommandArgument);
break;
case "Submit":
// Display a message for the Submit button being clicked.
Message.Text = "You clicked the Submit button";
// Test whether the command argument is an empty string ("").
if((String)e.CommandArgument == "")
{
// End the message.
Message.Text += ".";
}
else
{
// Display an error message for the command argument.
Message.Text += ", however the command argument is not recogized.";
}
break;
default:
// The command name is not recognized. Display an error message.
Message.Text = "Command name not recogized.";
break;
}
}
void Sort_List(string commandArgument)
{
switch(commandArgument)
{
case "Ascending":
// Insert code to sort the list in ascending order here.
Message.Text = "You clicked the Sort Ascending button.";
break;
case "Descending":
// Insert code to sort the list in descending order here.
Message.Text = "You clicked the Sort Descending button.";
break;
default:
// The command argument is not recognized. Display an error message.
Message.Text = "Command argument not recogized.";
break;
}
}
</script>
</head>
<body>
<form id="form1" runat="server">
<h3>Button CommandName Example</h3>
Click on one of the command buttons.
<br /><br />
<asp:Button id="Button1"
Text="Sort Ascending"
CommandName="Sort"
CommandArgument="Ascending"
OnCommand="CommandBtn_Click"
runat="server"/>
<asp:Button id="Button2"
Text="Sort Descending"
CommandName="Sort"
CommandArgument="Descending"
OnCommand="CommandBtn_Click"
runat="server"/>
<br /><br />
<asp:Button id="Button3"
Text="Submit"
CommandName="Submit"
OnCommand="CommandBtn_Click"
runat="server"/>
<asp:Button id="Button4"
Text="Unknown Command Name"
CommandName="UnknownName"
CommandArgument="UnknownArgument"
OnCommand="CommandBtn_Click"
runat="server"/>
<asp:Button id="Button5"
Text="Submit Unknown Command Argument"
CommandName="Submit"
CommandArgument="UnknownArgument"
OnCommand="CommandBtn_Click"
runat="server"/>
<br /><br />
<asp:Label id="Message" runat="server"/>
</form>
</body>
</html>
分享到:
相关推荐
btnPrev.CommandName = (GridView1.PageIndex == 0 ? "1" : GridView1.PageIndex.ToString()); btnNext.CommandName = (GridView1.PageCount == 1 ? GridView1.PageCount.ToString() : (GridView1.PageIndex + 2)....
1.选择gridview控件,创建按纽列buttonfield,将此按纽列的CommandName 设置为Details //本例是为了想要查看改行的详细信息 2.GridView1的属性: OnRowCommand= “btnOpenClick” DataKeyNames=”p_num” //绑定...
这里写了两种关于CommandName和CommandArgument的使用,一类是在后台写代码实现,一类是直接在控件付给属性值
Skyflow-开发人员的最好朋友 Skyflow使开发人员的生活更加轻松。 先决条件 Skyflow是在Nodejs中开发的。 您需要或 。 安装 与npm npm install skyflow-cli-g ... commandName : { description : "Description
commandname --command description. commandname2 --command description. commandname3 --command description. commandname4 --command description.' ); break ; case 'commandname' : $ array [ 'output' ] =...
添加命令时,可以先创建一个名为“ commands ”的文件夹,然后以commandname.js的形式安装一个js文件。 您可以从Events文件夹中的ready.js文件内部更改Bot的状态。 ================= ERN#2088编码 ============...
中性 neu cli用于Neutralinojs $ npm i -g @neutralinojs/neu概要neu create <binaryName> neu build [--release] neu run ... exports = { command : 'commandname <action1>' , register : ( command , modules ) =>
线计数器 要求: 支持的操作系统:Windows,Linux,MacOS 怎么运行的? 控制台应用程序读取带有数字枚举(由','分隔)的文件行,并找到具有最大总和... "commandName": "Project", "commandLineArgs": "\"argument1\
执行并打印tldr commandname 。 然后从您的研究中执行该命令的一些示例。 :open_file_folder: 项目文件 文档名称 描述 .gitignore 一般忽略文件。 针对Python进行了优化。 .dockerignore 生成期间将不会复制的...
您的不一致机器人令牌commandPrefix *-命令事件的全局前缀allowGuilds允许机器人使用的公会ID列表denyGuilds该机器人使用的公会ID列表allowChannels将命令链接到通道(也可以通过装饰器设置) commandName *-命令...
设置CommandName和CommandArgument属性,这样当通过LinkButton引发RowCommand事件时,相关的列都可以隐藏。以前隐藏的列索引存储在一个List中,这些列在建立时,将会被隐藏的。 代码 protected void GridView1_...
<asp:Button ID="AddButton" runat="server" CommandName="AddToCart" CommandArgument="((GridViewRow) Container).RowIndex %>" Text="Add to Cart" /> </ItemTemplate> </asp:TemplateField> 为 ...
为了让DataList有编辑和删除的功能,我们在ItemTemplate里添加了一些button,当点击时,引起postback,并根据button的CommandName属性激发相关的事件。例如,添加一个CommandName为“Edit”的button,在postback时会...
利用e.CommandSource 代码如下: protected void lpg_RowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName == “ItemCollect”) { GridViewRow gvr = (GridViewRow)(((LinkButton)(e.Command...
4.Button控件的onclick、oncommand、commandname、CommandArgument的区别 . . . Ajax(Asynchronous JavaScript + XML)的定义 使用模型窗口时,重复打开画面的解决方法 解决IIS写Excel的权限问题 脚本发生错误 ...
protected void Button1_Click(object sender, EventArgs e) { for (int i = 0; i <= GridView1.Rows.Count - 1; i++) { CheckBox cbox = (CheckBox)GridView1.Rows[i].FindControl("CheckBox1"); if (cbox....
要从CMD中自由调用该程序,请创建一个批处理文件(commandname.cmd)并将其放在PATH(PATH环境变量)的文件夹中。 将其放在commandname.cmd文件中: @echo off cd /d \folder\to\the\compiled\sources java ...
代码如下:CommandName=”id_” CommandArgument='<%#Eval(“id_comments_”)+”,”+Eval(“iscertification_comments_”) %>’ OnCommand=”comment_click” 代码如下:protected void ...
<asp:LinkButton ID="LinkButton1" runat="server" CommandName="update">保存</asp:LinkButton> <asp:LinkButton ID="LinkButton2" runat="server" CommandName="Cancel">取消</asp:LinkButton> <asp:...
5.5.2 CommandName属性 123 5.5.3 使用客户端JavaScript的按钮 124 5.6 LinkButton服务器控件 126 5.7 ImageButton服务器控件 126 5.8 HyperLink服务器控件 128 5.9 DropDownList服务器控件 128 5.10 从集合中...