Click here to Skip to main content
14,453,349 members
Rate this:
Please Sign up or sign in to vote.
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;

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
   
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
Rate this:
Please Sign up or sign in to vote.

Solution 3

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.
   
Rate this:
Please Sign up or sign in to vote.

Solution 1

Have a look VB.NET/C# and JavaScript communication[^]. This pretty much explains a good approach.
   
Comments
   
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.
Rate this:
Please Sign up or sign in to vote.

Solution 2

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.
   
v4
Comments
saxenaabhi6 18-May-11 1:16am
   
Please give a reason to downvote.
Rate this:
Please Sign up or sign in to vote.

Solution 4

By searching google or any search engine site.
   

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




CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100