命令参数为空
我想这样做:
<asp:ImageButton runat="server" ID="addToCartIMG" OnCommand="btnAdd_Click" EnableViewState="false" CommandArgument='<%# itemId1.Value + ";" + Name1.Text %>' ImageUrl="<%$Resources:MasterPage, Image_AddToCart%>" />
其中 Item1 是隐藏字段,Name1 是文字。
当我调试 btnAdd_Click 方法时,CommandEventArgs 为空,我不明白为什么......
谢谢
I would like to do this :
<asp:ImageButton runat="server" ID="addToCartIMG" OnCommand="btnAdd_Click" EnableViewState="false" CommandArgument='<%# itemId1.Value + ";" + Name1.Text %>' ImageUrl="<%$Resources:MasterPage, Image_AddToCart%>" />
where Item1 is hiddenField and Name1 a literal.
When I debug the method btnAdd_Click, the CommandEventArgs is empty and I don't understand why...
Thank you
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您无法像示例中那样评估表单字段的值。如果您尝试评估的这些值是静态的,我的意思是不会因用户的操作而改变,您可以将它们静态地传递给按钮的 CommandArgument 属性。
如果这些值因用户的操作而改变,那么您应该通过控件的引用在服务器端获取它们,如下所示:
对于 LiteralControl,您无法获取它的文本。你应该把它变成表单元素。
Eval 方法不是将控件的值动态传递到服务器的客户端函数。
You can't evaluate form field's values as you do in your example. If these values you try to evaluate are static, I mean doesn't change by your user's actions, you can pass them statically to your button's CommandArgument property.
If the values are changing by your user's actions, then you should get them at server-side by the reference of your controls like that :
For LiteralControl, you can't get it's text. you should turn it to form element.
Eval method is not a client-side function that passes your controls' values dynamically to server.