Click here to Skip to main content
15,881,600 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi everyone,
How can I call the codebehing event handler for a button from a clientside javascript event in ASP.net.

If I have
protected void ASPxGridView1_FocusedRowChanged(object sender, EventArgs e)
        {
            x++;
            txt_id.Text = x.ToString();
            txt_address.Text = ASPxGridView1.GetSelectedFieldValues("id").ToString() + "l";
        }

So how can I call this from a clientside javascript event.

Thanks for any help!

[edit]added codeblock, spelling and grammar[/edit]
Posted
Updated 3-Apr-11 8:02am
v4
Comments
Ali Al Omairi(Abu AlHassan) 3-Apr-11 14:01pm    
hi mostafa;
i think you should add the onclick attribute to the row in RowDataBound event.
Manfred Rudolf Bihy 3-Apr-11 14:04pm    
Sounds kind of logical. Why don't you post that as a solution?
It might fetch you a couple of points. :)
Ali Al Omairi(Abu AlHassan) 4-Apr-11 3:09am    
sir; you know what, I hate points.
Ali Al Omairi(Abu AlHassan) 4-Apr-11 7:03am    
you tricked me, sir. I was down voted.
Manfred Rudolf Bihy 4-Apr-11 9:03am    
I'm sorry for that Ali, but I just compensated the downvote with a 5.
Rest asured that I did not try to trick you. :)

possi ya basha;

on the event RowDataBound add the code:

scharp
e.Row.Attributes.Add("onclick", GetPostBackEventReference(this,"RowClick$" + e.Row.RowIndex.ToString());


.., then implement IPostBackEventHandler

scharp
public void RaisePostBackEvent(string eventArgument){
string[] args = eventArgument.Split('$');
if(args[0] == "RowClick"){
// do something.
}
}


eshtta yaba !!?

100 :rose:
 
Share this answer
 
v3
if you search in codeproject you could have found the answer :-), nevertheless, this is an excellent question, please do check the link Calling ASP.NET server-side events using JavaScript[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900