
Originariamente inviata da
supermac
Un aiutino: devi indicare runat="server" e devi dargli un id.
Nel codebehind poi lo vedi come oggetto di tipo HtmlGenericControl
Ora basta sennò mi cazziano ;-)
ciao
non so. Non ho trovato l'evento click né nel panel né nel div runat server (ma forse mi sbaglio)
io faccio così:
codice:
<%@ Page Language="VB" %>
<!DOCTYPE html>
<script runat="server">
Private Sub LinkButton1_onclick(sender As Object, e As System.EventArgs)
Me.ClientScript.RegisterStartupScript(Me.GetType, "1", String.Format("document.getElementById(""div1"").innerHTML = ""Cliccami<br><br>{0}"";", DateTime.Now.ToString), True)
End Sub
</script>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<meta http-equiv="Content-Type" content="text/html; charset=utf-8"/>
<title></title>
<script type="text/javascript">
// <=!=[=C=D=A=T=A=[
function div1_onclick(v)
{
<%=Me.ClientScript.GetPostBackEventReference(Me.LinkButton1, "") %>;
}
// ]=]=>
</script>
</head>
<body>
<form id="form1" runat="server">
<asp:LinkButton ID="LinkButton1" runat="server" style="display:none;" OnClick="LinkButton1_onclick">LinkButton</asp:LinkButton>
<div id="div1" onclick="div1_onclick(this);" style="width:100px; height:100px; background-color:yellow;color:red; padding:4px;">
Cliccami
</div>
</form>
</body>
</html>