我有这样的简单代码...如下...

<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="Default.aspx.vb" Inherits="AlinmaWebApp._Default" %> 
 
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> 
 
<html xmlns="http://www.w3.org/1999/xhtml" > 
<head runat="server"> 
    <title>Untitled Page</title> 
    <style type="text/css"> 
        #formHt 
        { 
            height: 284px; 
        } 
        .DivStyle 
        { 
            height :250px; 
            background-color :Green ; 
            display : block; 
        } 
 
    </style> 
 
<script language="javascript" type ="text/javascript" > 
 
    function TryClose() { 
        document.getElementById("DivBah").style.height = '1px'; 
        document.getElementById("DivBah").style.display = 'none'; 
        return; 
    } 
</script> 
 
 
</head> 
<body onload="TakeIT() return;" > 
    <form id="formHt" runat="server"> 
    <div id="DivBah" class="DivStyle" > 
        Just Try if this part will Collapse or not</div> 
    <asp:Button ID="Button1" runat="server" Text="Button" OnClick="TryClose()"/> 
    </form> 
</body> 
</html> 

这给了我错误消息,例如=>“TryClose”不是“default_._ASPX”的一部分 这种类型的编码可能会出现什么错误? 因为我以前在简单的 ASP 程序中总是使用这种类型。

请您参考如下方法:

试试这个:

<asp:Button ID="Button1" runat="server" Text="Button" OnClientClick="TryClose()"/> 

OnClick 用于服务器端点击事件。


评论关闭
IT虾米网

微信公众号号:IT虾米 (左侧二维码扫一扫)欢迎添加!