Call a asp.net function from a javascript function

Hi, I have this code  

 
1     <script type="text/javascript">
2    window.pageLoad = function(){
3        $addHandler($get('btnSuccess'), 'click', loginSuccess); 
4    }
5    
6    </script>
7    
8    <asp:Button runat="server" CssClass="booking" ID="btn_1" OnClick="SendInfo" />
9                                                "mpe1" runat="server" TargetControlID="btn_1"
10                                                   PopupControlID="pnl1" BackgroundCssClass="modalBackground">
11                                               "pnl1" runat="server" Style="display: none;" CssClass="modalPopup">
12                                                   "up1" runat="server" UpdateMode="Conditional">
13                                                       
14                                                           "#" onclick="closePopup();return false;">Close
15                                                           <button id="btnSuccess">Success</button>
16                                                       
17   
 

 In a first time I want to know if it's possible to call the SendInfo function? If it's not, I want to know how can i call SendInfo instead of loginSuccess from the Javascript.

Thanks a lot

0
deathsurfer
4/2/2009 5:12:52 AM
asp.net.ajax-ui 9760 articles. 0 followers. Follow

3 Replies
1106 Views

Similar Articles

[PageSpeed] 25
Get it on Google Play
Get it on Apple App Store

As in the code snippet if the "SendInfo" function is the event function of the button "btn_1" then generate a button click of that button through javascrpt that will do the task for you

This can be done in the following way in the javascript function


var btn = document.getElementById('btn_1');
if(btn!=null)
  btn.click();

if master page is used

use
var btn = document.getElementById('<%=btn_1.ClientID%>');

This will generate a button click event and in turn it will execute the function SendInfo

 


Or else you can achieve postback using __doPostBack function in javascript

0
jeeth
4/2/2009 5:53:08 AM

Hi,

Based on my understanding, you want to call a server-side event by JavaScript. Please check this link: http://forums.asp.net/t/1227950.aspx

 



Vince Xu
Microsoft Online Community Support
Please remember to mark the replies as answers if they help and unmark them if they provide no help.
0
Vince
4/6/2009 2:26:19 AM

You can use jQuery to call server side function

http://encosia.com/2008/05/29/using-jquery-to-directly-call-aspnet-ajax-page-methods/


Chetan Sarode
Software Engineer,
Approva Systems Pvt Ltd,
Pune, India.
0
chetan
4/6/2009 2:34:08 AM
Reply:

Similar Artilces:

How to call server side function by javascript using Ajax.Net
Sir, I want to call the server side function by javascript function. Is it possible using Ajax.Net (System.Web.Extensions.dll or AjaxControlToolkit.dll)? If yes then please give me the code or URL. I found some article using Ajax.dll but I want to use System.Web.Extensions.dll or AjaxControlToolkit.dll. Please help me. Thanks in advance Paresh        Hi, Ajax.NET and ASP.NET AJAX, what you want, are completely different implementations so please be sure to use the correct terminology in the future as there are already 100+ AJAX frameworks aroun...

calling a function in .NET from javascript
Hi, I have 2 files, test.aspx and trial.js, i have a method called testrun() in test.aspx which is written in VB.net. How do i call this function using javascript? Thanks so much in advance, i would appreciate any help at all.. -stan  post your test.aspx code and I can alter it for you, so you can see the difference.---------------------------------------MCP - Web Based Client Development .NET 2.0  Well first off, the VB.net code is running on the server and the javascript is running on the client.  You'll need to get some sort of signaling between the client...

Call JavaScript function from VB.NET
Hi again, do you know how can I call a javascript function from the server side in VB.NET? Thanks!! You can't call Javascript functions directly form the server but you can get a script to run when the page loads on the client: Put this in your Page_Load event: Page.RegisterStartupScript("popup", "<script>alert('Message Saved');</script>") Modify it to call whatever function you want. Hope this helps, Nic...

how to call a .net function with a parameter in javascript?
 Suppose I have a VB.NET function as:public sub test(byval mystring as string).... end sub Then I want to call this sub to do something in script. How to write the code to call this sub with the parameter get from javascript? following way not work:var para ='mystrig';var call = '<%=test(para)%>'  Your script is running in the Browser. You want to do something on the server.The best way i believe is to have the function exposed as webmethod, and make an asynchronous call to get the response/do some server processingYou could also look into scriptca...

How do I call a .NET function using javascript?
Hey all, I would like to develop a firefox extension. I know I need to write in JavaScript - how do I call a function/dll that I wrote under c# and use it through my JavaScript code? Is there any module I can use? Thanks in advanced, YoS. ...

calling a javascript function from VB.net
Hi, does anyone know how to call a function written in javascript in a .js files using vb.net without doing it on events. I just want to call them when i need them and not during events(onchange, onBlur...etc) Thank you so much in advance..  Take a look at my post on ClientCallbacks here : http://forums.asp.net/t/1118172.aspx   Eric...

want to call a function of c#.net from javascript
hi everyone. i want to call a function of c#.net from javascript. and i also want to pass an argument from javascript to  that function. can anyone help me? thanks in advance. shweta  ThanksshwetaIn a day when don't come across any problem -you can be sure that you are traveling in wrong path Can you be more precise about the effect you're trying to achieve?  Explain you requirements , what you want to achieve be thisIf this post helps you, please mark it as Answer.Cheers,Muhammad Rizwan JavedSr .Net DeveloperAim 168, Dubai, UAE. Hi Try this, U'r Codeb...

Calling a Javascript Function from within .NET Codebehind
I know this is probably a tivial issue for most of you but I would like to be able to call a javascript function from a button click event in the .NET codebehind secition of my app. I have tried several approaches all to no avail. Her is some code I tried: Private Sub btnBeachRules_Click(ByVal sender As System.Object, ByVal e As System.Web.UI.ImageClickEventArgs) Handles btnBeachRUles.Click popupwindow("http://www.mydomain.com/beachrules/beachrules.aspx") End Sub Private Sub popupwindow(ByVal winname As String) Dim sb As New System...

how to call vb.net functions or procedures from javascript?
Can anyone please tell me how to call vb.net functions or procedures from javascript? You cannot directly call serverside ASP.NET methods if thats the question.Mike Schellenberger - MCAD You can, however get client-side code to raise server-side events on existing controls... Page.GetPostBackEventReference(ControlOfInterest)...

Is it possible to call a VB.NET function in javascript?
Hi, In this code I show an alert. But instead of the alert it has to do a function. Since it's not possible to connect to an sql database with javascript I need to do this in a function in my VB script section.That function I would like to call in my javascript when my javascript function is called. Here is the javascript code:function GetKeyPress() { alert(window.event.keyCode) }   Many thx in advance !! Hi, I hope you meant VB.NET and not vbscript. Check a post of mine over here How to call Server Side function from Client Side Code using PageMethods in ASP.N...

how to call Javascript function from VB.net but not onclick()
 Hi, I'm just wondering how can I call a function that is written in Java Script from a VB.net page? I know that I can add it to the onclick event of a button, but the thing is I want to call the javascript later on in the code and not instantly when I click the button.. is there a way?   On a page load event you can just use: btn.Attributes.Add("onclick", "MyFunction()")Please mark anything that helped you out as an answer.   dubsdj: Hi, I'm just wondering how can I call a function that is written in Java Script from a VB.n...

How can I use JavaScript to call .NET function?
Hi,   I want to use javascript to call .net function like this  protected void somefunction(object sender, EventArgs e) {         MultiView1.ActiveViewIndex = 3; }  I've used this method but it doesn't work like I want In aspx page <script language="javascript" type="text/javascript">function receivceCallFromFlash() { var location= "uk";CallServer(Location, ""); } </script>   <script language="javascript" type="text/javascript">functi...

How to call javascript function in .NET VB code?
I tried to call js function as below in .NET VB code, but it did not work. No error, no response.  Page.ClientScript.RegisterStartupScript(Me.GetType(), "myfunc", "alert('aaa');") Hi,Try this:this.ClientScript.RegisterStartupScript(this.GetType(), "showmessage", "alert('Hello World');", true); //last parameter will add the script tags automatically.Hope this helps. Best Regards,RajaMCAD .Net, MCDBAPlease choose "Mark as Answer" for the post that leads you to a solution Thanks for response. Page.ClientScript....

VB.NET
Hi, I've been looking for a solution for a while now and haven't been very successful so hopefully someone can help me out here. I have a timer on my aspx page which starts at 4 hours and goes all the way to 0 hours 0 minutes and 0 seconds remaining. I need to call a function in my code behind when there is only 1 hour remaining.How can i call this function from javascript. I hope someone can help me out. Thanks in advance!Ravina BrarSoftware DeveloperUniversity Of Alberta--------------------------The man who smiles when things go wrong has thought of someone to blame it on. - Rob...

call javascript function from code behind with vb.net
I have a javascript function in the head section of a form. From the code behind of this form, I want to call the function with vb.net. How do I do this? Thanks. Page.RegisterStartupScript.Bertrand----This posting is provided "AS IS" with no warranties, and confers no rights....

Web resources about - Call a asp.net function from a javascript function - asp.net.ajax-ui

JavaScript Kit- Your comprehensive JavaScript, DHTML, CSS, and Ajax stop
Your comprehensive JavaScript, DHTML, CSS, and Ajax stop

Let's Code: Test-Driven Javascript by James Shore — Kickstarter
James Shore is raising funds for Let's Code: Test-Driven Javascript on Kickstarter! A screencast series focusing on rigorous, professional Javascript ...

Eloquent JavaScript: A Modern Introduction to Programming
... and pragmatics. I loved the tutorial-style game-like program development. This book rekindled my earliest joys of programming. Plus, JavaScript! ...

Lightbox (JavaScript) - Wikipedia, the free encyclopedia
On a Lightbox-enabled page, a user can click an image to have it magnified in a Lightbox window, which resizes itself according to the size of ...

Open Directory - Computers: Programming: Languages: JavaScript: Tools: Obfuscators
about dmoz - help Top : Computers : Programming : Languages : JavaScript : Tools : Obfuscators Tools for obfuscation/compression JavaScript code. ...

Facebook File-Transfer App Pipe Relaunches, Now Works Via JavaScript, WebRTC
... allowed Facebook users to send and receive files up to 1 gigabit in size. A new version of Pipe debuted Monday, and the app now works via JavaScript ...

Under the Hood: The JavaScript SDK - The use of polyfills - Facebook
Facebook Engineering hat eine Notiz mit dem Titel Under the Hood: The JavaScript SDK - The use of polyfills geschrieben. Du kannst den vollständigen ...

JavaScript SDK - Facebook-Entwickler
Overview The JavaScript SDK provides a rich set of client-side functionality for accessing Facebook...

Senior Front-End Developer (Javascript and AJAX)
Company: Sometrics Category: Software Development Location: Los Angeles, CA How to Apply: jobs@sometrics.com Description: We are looking for ...

Badass JavaScript (@badass_js) on Twitter
WebGLWorker is an open source library that allows using WebGL from Web Workers. Great work as always from @kripken . blog.mozilla.org/research/2014/… ...

Resources last updated: 12/10/2015 1:53:45 AM