Solved

Verify using AJAX on page load

Posted on 2014-03-25
2
348 Views
Last Modified: 2014-03-31
Hi all,

I have a verify.aspx page.

I would like to load the page initially, then use ajax and a web method to run a some db function.

Does anyone have any ideas how I would load the page initally and then trigger the ajax call once the page has loaded?
0
Comment
Question by:flynny
[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
2 Comments
 
LVL 82

Accepted Solution

by:
leakim971 earned 500 total points
ID: 39954640
Using PageMethod it's easy :

http://msdn.microsoft.com/en-us/library/system.web.ui.scriptmanager.enablepagemethods(v=vs.110).aspx
http://msdn.microsoft.com/en-us/library/bb398998(v=vs.110).aspx/#code-snippet-7

[System.Web.Services.WebMethod]        
public static string RunDBFunction()
{
      // DO YOUR DB STUFF
}

Open in new window


window.onload = function() {
      PageMethods.RunDBFunction(onSucceed, onError);
}
function onSucceed(result) {
      alert(result);
}
function onError(result) {      
}

Open in new window

0
 
LVL 8

Expert Comment

by:johny_bravo1
ID: 39965108
I would go for master page instead and make a call to the webservice from jquery on master page.
0

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

Suggested Solutions

jQuery is a JavaScript library that greatly simplifies JavaScript programming. AJAX is an acronym formed from "Asynchronous JavaScript and XML."  AJAX refers to any communication between client and server, when the human client does not observe a…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

751 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