Go Premium for a chance to win a PS4. Enter to Win

x
?
Solved

Javascript do postback and run vbnet sub

Posted on 2014-01-20
1
Medium Priority
?
1,151 Views
Last Modified: 2014-01-21
Is there a way to run a vbnet sub script via javascript?

Thanks,

WCGee
0
Comment
Question by:williecg
1 Comment
 
LVL 83

Accepted Solution

by:
leakim971 earned 2000 total points
ID: 39795922
You can use PageMethods :
http://www.dotnetcurry.com/showarticle.aspx?ID=109
http://msdn.microsoft.com/en-us/library/system.web.ui.page_methods(v=vs.110).aspx

Add this in your page :
<asp:ScriptManager ID="ScriptManager1" runat="server" EnablePageMethods="true"/>

Open in new window


Public Shared Function FunctionName(ByVal parame As String) As String
' DO SOMETHING
End Function

Open in new window


Javascript, client side :
function RunServerSideFunction(fieldID, target) {    
     var value = document.getElementById(fieldID).value;
     PageMethods.FunctionName(value, Success, Failed, target);
}
 
function Success(result, fieldID) {    
    document.getElementById(fieldID).value = result;
}
 
function Failed(error, fieldID) {
     alert(error);
}

Open in new window

0

Featured Post

How to Use the Help Bell

Need to boost the visibility of your question for solutions? Use the Experts Exchange Help Bell to confirm priority levels and contact subject-matter experts for question attention.  Check out this how-to article for more information.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Having trouble getting your hands on Dynamics 365 Field Service or Project Service trial? Worry No More!!!
The Windows functions GetTickCount and timeGetTime retrieve the number of milliseconds since the system was started. However, the value is stored in a DWORD, which means that it wraps around to zero every 49.7 days. This article shows how to solve t…
The viewer will learn how to dynamically set the form action using jQuery.
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…
Suggested Courses

885 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question