我有带有CommandArgument属性的ImageButton,它具有多个Eval值.当我单击其中一个时,我想将值传递给ImageButton2_Click事件,但它不起作用,因为Command参数为null.
<div class="sag-re-icerik" id="icerik2" runat="server">Lorem ipsum dolor sit amet, consectetur commodo et convallis et, auctor viverra metus. Aenean pharetra, arcu nec viverra mollis, turpis neque feugiat massa, non dapibus neque nunc ac orci. </div>
<div class="oy-verme">
<div class="yildiz"><asp:ImageButton ID="ImageButton4" runat="server" Height="19px" ImageUrl="~/images/yildiz.png" onclick="ImageButton2_Click" Width="20px" style="position: relative; top: 13px; left:6px; float:left; " commandArgument='<%#Eval("sdasdas") + ","+Eval("fafasfa") %>' /></div>
<div class="yildiz"><asp:ImageButton ID="ImageButton5" runat="server" Height="19px" ImageUrl="~/images/yildiz.png" onclick="ImageButton5_Click" Width="20px" style="position: relative; top: 13px; left:8px; float:left;" commandArgument='<%#Eval("row[0].ToString()") + ","+Eval("row[1].ToString()") %>'/></div>
<div class="yildiz"><asp:ImageButton ID="ImageButton6" runat="server" Height="19px" ImageUrl="~/images/yildiz.png" …
Run Code Online (Sandbox Code Playgroud) 我有一个包含多行的gridview,每个都有一个Update按钮,当有人点击Update按钮时我需要传递2个值.除了用逗号分隔CommandArgument内的参数(古老而不优雅)之外,我如何传递多个参数?
<asp:LinkButton ID="UpdateButton" runat="server" CommandName="UpdateRow" CommandArgument="arg_value" Text="Update and Insert" OnCommand="CommandButton_Click" ></asp:LinkButton>
Run Code Online (Sandbox Code Playgroud)
请注意,无法从页面上的任何控件中检索值,因此不提供任何设计解决方案.请专注于提出的问题.提前致谢.
我正在使用C#开发一个asp.net应用程序.我创建了一个.aspx页面,并在页面的不同位置放置了四个按钮.在服务器端,我想对所有四个按钮只使用一次单击事件.
这是我的代码:
aspx页面
<asp:Button ID="Button1" runat="server" CommandArgument="Button1" onClick = "allbuttons_Click" />
<asp:Button ID="Button2" runat="server" CommandArgument="Button2" onClick = "allbuttons_Click" />
<asp:Button ID="Button3" runat="server" CommandArgument="Button3" onClick = "allbuttons_Click" />
<asp:Button ID="Button4" runat="server" CommandArgument="Button4" onClick = "allbuttons_Click" />
Run Code Online (Sandbox Code Playgroud)
cs页面
protected void allbuttons_Click(object sender, EventArgs e)
{
//Here i want to know which button is pressed
//e.CommandArgument gives an error
}
Run Code Online (Sandbox Code Playgroud) 我必须将两个参数传递给我的main方法.我的构建脚本是
// Apply the java plugin to add support for Java
apply plugin: 'java'
// In this section you declare where to find the dependencies of your project
repositories {
// Use 'maven central' for resolving your dependencies.
mavenCentral()
}
// In this section you declare the dependencies for your production and test code
dependencies {
compile 'com.example:example-core:1.7.6'
}
task main(type: JavaExec, dependsOn: classes) {
description = 'This task will start the main class of the example project'
group = …
Run Code Online (Sandbox Code Playgroud) 我正在尝试使用命令行参数从命令行运行R. 这包括传入一些文件路径作为在脚本中使用的参数.它大部分时间都有效,但有时路径中有空格而R不理解.
我正在运行以下形式:
R CMD BATCH --slave "--args inputfile='C:/Work/FolderWith SpaceInName/myinputfile.csv' outputfile='C:/Work/myoutputfile.csv'" RScript.r ROut.txt
Run Code Online (Sandbox Code Playgroud)
R抛出一个文件说
Fatal error: cannot open file 'C:\Work\FolderWith': No such file or directory
Run Code Online (Sandbox Code Playgroud)
所以我的单引号显然不足以告诉R将引号内的所有内容作为参数值.我在想这意味着我应该找到一种方法来分隔我--args
使用逗号,但我找不到办法来做到这一点.我确信这很简单,但我在文档中找不到任何内容.
当前脚本非常基本:
ca = commandArgs(trailingOnly=TRUE)
eval(parse(text=ca))
tempdata = read.csv(inputFile)
tempdata$total = apply(tempdata[,4:18], 1, sum)
write.csv(tempdata, outputFile, row.names = FALSE)
Run Code Online (Sandbox Code Playgroud)
如果它是相关的我正在使用Windows,但它似乎不是一个cmd提示问题.
我有一个ASP.Net页面,它向用户显示一个选项列表.当他们从列表中选择时,它会回发并查询sql server.结果显示在更新面板中选项下方的列表视图中.下面是ItemTemplate的片段:
<asp:LinkButton Text="Save IT" OnCommand="SaveIt" CommandArgument="<%# Container.DataItemIndex %>" runat="server" />
Run Code Online (Sandbox Code Playgroud)
DataItemIndex没有出现,所以我的commandargument是空的.但是,对象发件人是显示项目的按钮.
为什么索引项不出现在CommandArgument中?
可能是帖子回来了吗?如果是这样,为什么会回帖?有办法解决吗?
编辑:对不起,从我之前尝试解决它,我发布了错误的代码,但它仍然没有出现.
解决方案:我找到了另一种解决方法,即OnCommand的发送者是链接按钮,它具有CommandArgument.我将粉笔这个问题成为多个回发和javascript的问题.
VS 没有使用我传入的“命令参数”运行。我做错了什么?
尝试在 Visual Studio 中使用“命令参数”。
我把它分解成一个简单的 C 语言小 ConsoleApplication 程序。
#include "pch.h"
#include <iostream>
int main(int argc, char *argv[])
{
printf("\nargv: ");
for (int i = 0; i < argc; i++)
{
printf(" %s", argv[i]);
}
printf("\n");
}
Run Code Online (Sandbox Code Playgroud)
然后我设置“命令参数”:项目:属性:调试:“命令参数”:妈妈
我点击了 RUN 按钮并显示了它(我的参数没有传入):
argv: C:\Users\jack\source\repos\ConsoleApplication45\Debug\ConsoleApplication45.exe
C:\Users\jack\source\repos\ConsoleApplication45\Debug\ConsoleApplication45.exe (process 1812) exited with code 0.
To automatically close the console when debugging stops, enable Tools->Options->Debugging->Automatically close the console when debugging stops.
Press any key to close this window . . .
Run Code Online (Sandbox Code Playgroud)
当我从命令行运行时,我得到(按我希望的方式使用传入的参数工作:“妈妈”):
C:\Users\jack\source\repos\ConsoleApplication45\Debug>ConsoleApplication45.exe …
Run Code Online (Sandbox Code Playgroud) 我有一个Repeater
包含标记为"更改成员资格"的链接,当点击该链接时会打开一个带有a radiobuttonlist
和a 的灯箱button
.当点击灯箱中的按钮时,我有一个回调事件,我需要先找到radiobutton列表的选定值,这里是转发器:
<script language="JavaScript" type="text/javascript">
function CreateBox(id) {
$(document).ready(function () {
$("#lnk" + id).fancybox({
'closeBtn': true,
helpers: {
overlay: { closeClick: false }
}
});
});
}
</script>
Run Code Online (Sandbox Code Playgroud)
<asp:Repeater ID="repProspects" runat="server" OnItemDataBound="repProspects_ItemDataBound">
<ItemTemplate>
<asp:HiddenField ID="hfRequestID" runat="server" Value='<%# DataBinder.Eval(Container, "DataItem.RequestID") %>' />
<asp:HiddenField ID="hfRecruiterNumber" runat="server" Value='<%# DataBinder.Eval(Container, "DataItem.RecruiterCardNumber") %>' />
<asp:HiddenField ID="hfCompanyID" runat="server" Value='<%# DataBinder.Eval(Container, "DataItem.CompanyID") %>' />
<asp:HiddenField ID="hfMemberType" runat="server" Value='<%# DataBinder.Eval(Container, "DataItem.MemberType") %>' />
<asp:HiddenField ID="hfLifeDuesAmount" runat="server" Value='<%# DataBinder.Eval(Container, "DataItem.Dues") %>' …
Run Code Online (Sandbox Code Playgroud) 我正在尝试在调用rowcommand时发送多个命令参数:
<asp:TemplateField HeaderText="Status">
<ItemTemplate>
<asp:Button ID="btnAct" runat="server" CausesValidation="False" CommandName="Action"
Text='De-Activate' CommandArgument='<%# Bind("isActiveYN") + ";" + Bind("employeeid") %>' />
<asp:Label ID="lblActivate" runat="server" Text='<%# Bind("isActiveYN") %>' Visible='False'></asp:Label>
</ItemTemplate>
</asp:TemplateField>
Run Code Online (Sandbox Code Playgroud)
然而,当我使用多个参数时,它只显示后半部分,在此employeeid
.如果我只指定一个参数,它就可以正常工作.
protected void gvEmp_RowCommand(object sender, GridViewCommandEventArgs e)
{
string changeactive = null;
if (e.CommandName == "Action")
{
//LinkButton lnkPortal = (LinkButton)sender;
string isactivestatus = Convert.ToString(e.CommandArgument);
string[] arg = new string[2];
arg = isactivestatus.Split(';');
//lblTest.Text = isavtivestatus.Text;
string status = Convert.ToString(arg[0]);
int empid = Convert.ToInt32(arg[1]);
if (status.ToUpper() == "Y")
{
lblTest.Text = …
Run Code Online (Sandbox Code Playgroud) 用这个失去理智.即使命令设置已设置,我的按钮也会获得空字符串的命令参数.我已经验证它在调试模式下被设置为正确的ID,但是当我稍后在转发器ItemCommand事件中访问此命令参数时,commandarguments是空字符串.我不明白为什么.我最终得到一个sq外键异常,因为它从空字符串值插入ID为0.关于将重置它的转发器按钮没有其他代码.
中继器:
<asp:Repeater ID="repeaterAddresses" ViewStateMode="Enabled" DataSourceID="sqlFacilityAddresses" runat="server">
<ItemTemplate>
<Select:Address ID="AddressControl" runat="server" />
<asp:Button ID="btnMarkAsBilling" runat="server" EnableViewState="true" CommandName="Billing" Text="Mark as billing address" />
<asp:button ID="btnMarkAsPhysical" runat="server" EnableViewState="true" CommandName="Physical" Text="Mark as physical address" />
</ItemTemplate>
</asp:Repeater>
Run Code Online (Sandbox Code Playgroud)
代码背后:
Protected Sub repeaterAddresses_ItemCreated(ByVal sender As Object, ByVal e As RepeaterItemEventArgs) Handles repeaterAddresses.ItemCreated
If Not IsNothing(DirectCast(e.Item.DataItem, DataRowView)) Then
If (e.Item.ItemType = ListItemType.Item) Or (e.Item.ItemType = ListItemType.AlternatingItem) Then
Dim addressControl As Address = DirectCast(e.Item.FindControl("AddressControl"), Address)
addressControl.AddressID = CInt(DirectCast(e.Item.DataItem, DataRowView)("Address_ID").ToString())
Dim btnBilling As Button = DirectCast(e.Item.FindControl("btnMarkAsBilling"), Button)
btnBilling.CommandArgument …
Run Code Online (Sandbox Code Playgroud)