How to run a method from codebehind when clicking on a
-
I am quite new to ASP.NET and hope that there is an easy answer to my question.. My question is how can I access an function from codeBehind when I click on a
in my application? I have a
tag and when I click on the tag I want to run a function from codebehind to do some calulationes and then redirect the user to a new web page. However the onclick event för the
tag is only for client side java scripts. Does anyone have a good answer? A.V
-
I am quite new to ASP.NET and hope that there is an easy answer to my question.. My question is how can I access an function from codeBehind when I click on a
in my application? I have a
tag and when I click on the tag I want to run a function from codebehind to do some calulationes and then redirect the user to a new web page. However the onclick event för the
tag is only for client side java scripts. Does anyone have a good answer? A.V
You can try calling a Javascript when the div is clicked. The Javascript should submit your form and you might want to add additional query string to let the page knows your div is clicked. From there it's all the same as a postback from a button. "Democracy is two wolves and a sheep voting on what to have for dinner" - Ross Edbert Sydney, Australia
-
I am quite new to ASP.NET and hope that there is an easy answer to my question.. My question is how can I access an function from codeBehind when I click on a
in my application? I have a
tag and when I click on the tag I want to run a function from codebehind to do some calulationes and then redirect the user to a new web page. However the onclick event för the
tag is only for client side java scripts. Does anyone have a good answer? A.V
Try this. In the Page_Load method in the codebehind put:
divButton.Attributes.Add("onclick",Page.GetPostBackEventReference(divButton));
NB. This needs to be executed everytime, so don't put it inside any if blocks. Now your page will post back when you click on the DIV. Next thing to do is to work out which control caused the postback so you can call a specific handler for your control. Check here for how to do this HTH -
I am quite new to ASP.NET and hope that there is an easy answer to my question.. My question is how can I access an function from codeBehind when I click on a
in my application? I have a
tag and when I click on the tag I want to run a function from codebehind to do some calulationes and then redirect the user to a new web page. However the onclick event för the
tag is only for client side java scripts. Does anyone have a good answer? A.V