Click here to Skip to main content
15,881,744 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
Hi Guys,
I have a situation....
I have to display one conformation(Yes/No) to user based on the server side logic. What I am planning was to write javascript in code behind itself.
But I have to call a serverside function if he clicks YES in conformation.

Do I have to implement ajax(WebMethods/Invoke attribute) to the server side function in order to make the server side function available to Javascript?
Or is there any other smart way to achive it.....

Thanks for your advice...
Posted

You can use ajax. you can call a .ashx or .aspx file.
Example:

var J = jQuery.noConflict();

function loadNextFiveStories() {
J.ajax({
url: "GetNextFiveStories.ashx",
type: "GET",
dataType: 'html',
data: { 'Next': id },
success: function (data) {

}
});
}
 
Share this answer
 
Not sure if this is what you are looking for.
<asp:LinkButton ID="lbAccept" runat="server" onclick="lbAccept_Click"
                                OnClientClick="return confirm('Are you sure you want to accept this ?')"
                                 ForeColor="Yellow" Font-Bold="True" style="font-size:18px">I Accept</asp:LinkButton>

This is just a simple link button that will show confirmation dialog box when user clicks on it and if user choose Yes then server side lbAccept_Click will be executed.
 
Share this answer
 
v2
Comments
virang_21 11-Oct-10 1:05am    
What is Edited in the answer ?
Ankur\m/ 11-Oct-10 1:14am    
I could see your lblAccept_Click selling was wrong. It was cilck.
This is a minor edit and the editor should have checked 'Minor Edit' while editing.
Sandeep Mewara 11-Oct-10 4:01am    
Revision link should show you the differences after an update.
virang_21 11-Oct-10 6:45am    
Yea it was typo .. I thought there was some issue with code but it wasn't the case ..

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