[英]Why can't a input tag be type submit?
I am trying to do: 我正在尝试做:
<input type="submit" runat="server" ... />
Error: 错误:
The base class includes the field 'btnEdit', but its type (System.Web.UI.HtmlControls.HtmlInputImage) is not compatible with the type of control (System.Web.UI.HtmlControls.HtmlInputSubmit).
Submit is a valid type, what is wrong here? 提交是有效类型,这是什么问题?
You are doing something else wrong, post more code. 您在做其他错误,请发布更多代码。 Appears that you are casting
btnEdit
as System.Web.UI.HtmlControls.HtmlInputImage
. 似乎您正在将
btnEdit
强制btnEdit
为System.Web.UI.HtmlControls.HtmlInputImage
。
There is nothing wrong with doing this, it will post fine: 这样做没有错,它将很好地发布:
<input type="submit" runat="server" name="bla" value="bla" />
The error message shows you already have a control/html element with id 'btnEdit' which is of type System.Web.UI.HtmlControls.HtmlInputImage. 错误消息显示您已经具有id为“ btnEdit”的control / html元素,其类型为System.Web.UI.HtmlControls.HtmlInputImage。
Did you inherit your webpage class from some base class and it is possible that the base class has that control already defined. 您是否从某个基类继承了网页类,并且基类可能已经定义了该控件。
使用常规的ASP.NET并启用提交行为:
<asp:Button ID="Button1" runat="server" Text="Foo" UseSubmitBehavior="true" />
Maybe the "btnEdit" was defined by the image button , and then change it to the submit . 也许“ btnEdit”是由图像按钮定义的,然后将其更改为Submit。
So , 所以,
1,You can change the System.Web.UI.HtmlControls.HtmlInputImage to the System.Web.UI.HtmlControls.HtmlInputSubmit at the design.cs file . 1,您可以在design.cs文件中将System.Web.UI.HtmlControls.HtmlInputImage更改为System.Web.UI.HtmlControls.HtmlInputSubmit 。
2,Just change the id name from btnEdit to anything... 2,只需将ID名称从btnEdit更改为任何内容即可...
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.