开发者

Howto add postbackurl equivalent property to <div runat="server" />

I need a div element to cause postback to the server. I can use window.location tough but then I think I won't be able to fire any event back on the server. How can I call the asp.net generated dopostb开发者_StackOverflowack function properly? Thx in advance


The idea is that I place a linkButton, and then I use it from the Div

<form id="form1" runat="server">
<div>    
    <div runat="server" ID="txtTest" style="cursor:pointer;" >Click the div</div>
    <asp:LinkButton ID="LinkButton1" runat="server" onclick="LinkButton1_Click" style="display:none;"></asp:LinkButton>

    <br /><asp:Literal runat="server" ID="txtDebug"></asp:Literal>
</div>
</form>

and code behind

protected void Page_Load(object sender, EventArgs e)
{
    if (!IsPostBack)
    {
        txtTest.Attributes.Add("onclick", "__doPostBack('"+LinkButton1.ClientID+"','')");
    }

}
protected void LinkButton1_Click(object sender, EventArgs e)
{
    txtDebug.Text = "click on div";
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜