<div>
Hi,
I'm working on a webforms app that was written 5 years ago. for 1 page, I need to add a function where when a user clicks a radio button, I need to go back to the server side, access db, do some calculation, then display a message to this user via a pop-up;
BEFORE this user can proceed and go to next page.
I'm thinking that I should add a "onclick=..." to the radio button, which will run a javascript, which will then make an Ajax call inside the Javascript; tfrom there I can access the db, do the calculation, format data, then return the result and display
it in an "alert" window.
Currently the radio button code in .aspx looks like this:
<asp TemplateField>
<ItemTemplate>
<input name ="ServiceSelected" type ="radio"
value = '<%# Container.DataItemIndex %>'
onload = "...."
onclick=" ..." ---> I'm thinking to add the "onclick" here, which will call a js function on this page
<%# IsChecked( ) %>
</>
</ItemTemplate>
I think that this approach should work; but I'm new to Ajax so I do not know the syntax - e.g.:
1) can I insert a "Onclick" event here in the above code, like I did? If so, what is the correct way to call the JavaScript?
2) inside the JavaScript, how do I make a ajax call to access db? or I should somehow call a code behind function (in the .aspx.cs file)?
I'm open to suggestion on what is the simplest way to achieve my goal ... this code already works in prod., so I want to modify as little as possible.
If someone can provide some sample code on what I have listed above, or point me to an existing post, I'd appreciate it very much!
Thanks a lot!
Claudia
</div>