Use Div Click Event As UpdatePanel's Trigger

Posted by Sharpcnet under ASP.NET on 1/6/2014 | Points: 10 | Views : 1771 | Status : [Member] | Replies : 2
I'm using a div as an Image button, as the ASP Imagebutton was causing a flash on click, no matter what.

The Div click raises a server side event to bind the grid and it works good. Just that the whole page loads. In order not to, I tried to have it as a trigger.

Now, it gives the error - 'div1 being reistered through RegisterAsyncPostBackControl or RegisterPostBackControl must implement either InamingContainer,IpostBackDataHandler, or IpostbackEventHandler'

ASPX:
<div id="div1" runat="server" class="search"></div>
<asp:UpdatePanel runat="server" updatemode="conditional">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="divSearch" EventName="Click"/>
</Triggers>
<ContentTemplate>
<asp:gridview....../>
</ContentTemplate>
</asp:UpdatePanel>
C#:
public partial class Home: System.Web.UI.Page, IPostBackEventHandler
{

protected void Page_Load(object sender, EventArgs e)
{
div1.Attributes["onclick"] = ClientScript.
GetPostBackEventReference(this, "div1_Click");
}

protected void div1_Click()
{
bindGrid();
}

public void RaisePostBackEvent(string eventArgument)
{
if (!string.IsNullOrEmpty(eventArgument))
{
if (eventArgument == "div1_Click")
{
div1_Click();
}
}
}
}


Any way to make this work?




Responses

Posted by: Allemahesh on: 1/7/2014 [Member] [MVP] Silver | Points: 25

Up
0
Down
See the below link:-

http://www.codeproject.com/Articles/20790/How-to-call-code-behind-methods-Server-side-script

Sharpcnet, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Sharpcnet on: 1/7/2014 [Member] Starter | Points: 25

Up
0
Down
Could you help me understand, how I could make my div click a trigger event in the updatepanel with those instructions??

Sharpcnet, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response