我设法在我的网络应用程序中添加了一个iamge按钮。我正在尝试“激活”此图像按钮作为我的主页按钮。例如,当我点击它时,它会将我引导到主页。
这是我的初始图片按钮代码。
<input type="image" id="myimage" style="height:53px;width:200px;" src="image/logo.jpg" />
这是在我添加了常用的html代码以激活图像按钮作为我的主页
之后<input type="image" id="myimage" style="height:53px;width:200px;" src="image/logo.jpg" a href="PoliceHomePage" />
不幸的是,在添加了ahref后我收到了这个错误。
Validation(HTML5): Attribute 'href' is not a valid attribute of element 'input'.
我研究并尝试这个并且错误仍然存在。
他们回复我这样的错误
Validation of viewstate MAC failed. If this application is hosted by a Web Farm or cluster, ensure that <machineKey> configuration specifies the same validationKey and validation algorithm. AutoGenerate cannot be used in a cluster.
那么什么是正确的代码?
的更新 的
我终于设法得到了它
<a href="PoliceHomePage.aspx"><img src="image/logo.jpg" id="myimage" style="height:53px;width:200px;"/></a>
答案 0 :(得分:1)
<a href="PoliceHomePage"><input type="image" id="myimage" style="height:53px;width:200px;" src="image/logo.jpg" /></a>
A是不同的标签,href是A的参数。
答案 1 :(得分:0)
只需将链接作为值添加到NavigateUrl属性即可 例如:
ImageButton1.ImageUrl="~/img.png"
ImageButton1.NavigateUrl="~/default.aspx"
试一试
答案 2 :(得分:0)
我认为你应该在“a”标签中使用“img”标签
<a href="PoliceHomePage"><img src="image/logo.jpg" alt="img"></a>
答案 3 :(得分:0)
你可以在你的页面上试试这个吗?
pages validateRequest =“false”enableEventValidation =“false”enableViewStateMac =“false”
答案 4 :(得分:0)
看来你正在使用type =“image”错误。与错误所说的一样,“验证(HTML5):属性'href'不是元素'input'的有效属性。” 请参阅此问题:Input Type image submit form value?
您可以使用ImageButton的PostBackUrl(获取或设置在单击ImageButton控件时从当前页面发布到的页面的URL),
或者这个:
<a href="/">
<img id="myimage" style="height:53px;width:200px;" src="image/logo.jpg" />
</a>
只需自定义重定向网址和图片的src。