Solved

Javascript do postback and run vbnet sub

Posted on 2014-01-20
1
1,118 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 500 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

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

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

In threads here at EE, each comment has a unique Identifier (ID). It is easy to get the full path for an ID via the right-click context menu. However, we often want to post a short link within a thread rather than the full link. This article shows a…
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 use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…
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…

636 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