Can I create an ASP.NET ImageButton that doesn't postback?

前端 未结 8 526
无人及你
无人及你 2020-12-11 17:25

I\'m trying to use the ImageButton control for client-side script execution only. I can specify the client-side script to execute using the OnClientClick property, but how d

8条回答
  •  Happy的楠姐
    2020-12-11 17:46

    Solution 1

    
    

    OR Solution 2

    
    

    In addition (solution 2), your javascript method may be in this form

    
    

    in code behind

    protected void Page_Load(object sender, System.EventArgs e)
    {
        if (this.IsPostBack) {
            string eventTarget = this.Request("__EVENTTARGET") == null ? string.Empty : this.Request("__EVENTTARGET");
            string eventArgument = this.Request("__EVENTARGUMENT") == null ? string.Empty : this.Request("__EVENTARGUMENT");
        }
    }
    

提交回复
热议问题