Solved

Verify using AJAX on page load

Posted on 2014-03-25
2
342 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
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

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Suggested Solutions

Title # Comments Views Activity
Problem to go to Web page 2 51
getting id from database 5 24
c# if statement weird reaction 3 29
Adjust the position 3 12
Wouldn’t it be nice if you could test whether an element is contained in an array by using a Contains method just like the one available on List objects? Wouldn’t it be good if you could write code like this? (CODE) In .NET 3.5, this is possible…
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…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
This video explains how to create simple products associated to Magento configurable product and offers fast way of their generation with Store Manager for Magento tool.

705 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

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now