Click here to Skip to main content
15,896,063 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Hello, I want to know how can I call VB.NET (Server Side) function to Javascript (Client Side). I want to insert function here in my Javascript code;

JavaScript
function ConfirmSave()

{

var Ok = confirm('Proceed to Save?');

if(Ok==true)
 return true;
else if(Ok!=true)
 return false;


 }


I want to execute the Save() function from my VB.Net code when I return true. Please Help me. I need it so badly. Thank you.
Posted
Comments
Sergey Alexandrovich Kryukov 18-May-11 0:54am    
Change your nick -- if you need to get something good, it's never "easy".
Was that you who vote "3" to all answers? Was that because those answers were not easy enough?
--SA
Abhinav S 18-May-11 1:21am    
:)
hemantwithu 18-May-11 1:28am    
OK

Adding to other answer, in order to talk to server from Javascript, there are few ways to interact:
1. XMLHttpRequest[^]
2. Callback[^]
3. WebService call[^]
4. PageMethod[^]

Pick one that suits you.
 
Share this answer
 
Have a look VB.NET/C# and JavaScript communication[^]. This pretty much explains a good approach.
 
Share this answer
 
Comments
Sergey Alexandrovich Kryukov 18-May-11 0:55am    
I up-voted by my 5. Good source, good to know.
Somebody votes "3" to all answer, which I cannot agree.
Please see my comment to the question above.
--SA
Abhinav S 18-May-11 1:21am    
Thanks SA.
can't you do this at your save button in aspx

<br />
<asp:Button OnClientClick='javascript:return confirm("Proceed to Save?");' id="Button1" runat="server" text="Save" onClick="Save" /><br />


will end up doing the same you want.
 
Share this answer
 
v4
Comments
saxenaabhi6 18-May-11 1:16am    
Please give a reason to downvote.
By searching google or any search engine site.
 
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