新手需要帮助:服务器错误
我正在创建网站的联系人页面,并希望在成功发送电子邮件后隐藏 div 元素。隐藏 Div 元素的 Javascript 函数:
function hideDiv(){
document.getElementbyId(contact-area).visible="visible";
}
通过在按钮元素中使用“onclick”来调用代码:
<asp:Button ID="submitbutton" runat="server" Text="Submit" onclick="hideDiv();" />
当我尝试加载页面时,出现以下服务器错误:“服务器错误第 37 行:
<asp:Button ID="submitbutton" runat="server" Text="Submit" onclick="hideDiv();" />
编译错误消息:)预期”。
我在网上查过这一点,但似乎无法弄清楚出了什么问题。
I am creating the contacts page of a website and want the div element to hide after a successful email has been sent. The Javascript function to hide a Div element:
function hideDiv(){
document.getElementbyId(contact-area).visible="visible";
}
The code is called the by using "onclick" in the button element:
<asp:Button ID="submitbutton" runat="server" Text="Submit" onclick="hideDiv();" />
I get the following server error when i try and load the page: "Server Error Line 37:
<asp:Button ID="submitbutton" runat="server" Text="Submit" onclick="hideDiv();" />
Compile error message: ) expected."
I have looked online for this but cannot seem to figure out what is wrong.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
将
onClientclick
替换为onclick
将解决您的问题,因此您的代码将是
Make
onClientclick
insted ofonclick
will resolve your issueso your code will be
这在网络表单中具有误导性。您不需要
onclick
,您需要onclientclick
。This is misleading in webforms. You don't want
onclick
, you wantonclientclick
.ASP.Net Button 有两个属性
OnClick
用于回发时挂钩服务器端方法。
OnClientClick
用于调用客户端方法。
因此,您的按钮标记将如下所示: -
我猜您只需要客户端功能,因此您需要在 JavaScript 中再添加一行。
ASP.Net Button has two properties
OnClick
It is used to hoop up server side method when postback occur.
OnClientClick
It is used to call client side method.
So your button markup will look like: -
I guess you only want client side functionality, so you need to add one more line in your javascript.