Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Javascript do postback and run vbnet sub

Posted on 2014-01-20
1
Medium Priority
?
1,138 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
1 Comment
 
LVL 82

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

The top UI technologies you need to be aware of

An important part of the job as a front-end developer is to stay up to date and in contact with new tools, trends and workflows. That’s why you cannot miss this upcoming webinar to explore the latest trends in UI technologies!

Question has a verified solution.

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

As with any other System Center product, the installation for the Authoring Tool can be quite a pain sometimes. This article serves to help you avoid making these mistakes and hopefully save you a ton of time on troubleshooting :)  Step 1: Make sur…
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 the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
In a recent question (https://www.experts-exchange.com/questions/29004105/Run-AutoHotkey-script-directly-from-Notepad.html) here at Experts Exchange, a member asked how to run an AutoHotkey script (.AHK) directly from Notepad++ (aka NPP). This video…

704 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