473,473 Members | 1,562 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

calling asp.net code behind function from window.onload javascript function

19 New Member
Hi Gurus,

I have a requirement like below. In my asp.net(C#) code behind file "MyPage.aspx.cs" file I have a function like below:

void PopulateAccount(int AccountNumber)
{
this.AccountNumber.Text = AccountNumber;
}

I want to call this function from JavaScript (inside the window.onload function) from my MyPage.aspx page, something like below:

window.onload = function()
{
// I need to call my PopulateAccount method inside this function so that it can populate the AccountNumber Text Box
}

is this possible ?. Please help me how to do this . I am using ASP.Net 1.1 with C#.



Thanks and Regards,
Amit
May 4 '07 #1
3 15563
acoder
16,027 Recognized Expert Moderator MVP
You can call server-side code on the client side using AJAX. See the AJAX links in the Offsite Links thread.
May 4 '07 #2
akg
19 New Member
You can call server-side code on the client side using AJAX. See the AJAX links in the Offsite Links thread.
acoder,
you have posted following links here. could you please tell me which one i should refer for my problem.

AJAX:Getting Started (Mozilla Developer Center)
http://www.xul.fr/en-xml-ajax.html (GET, POST, text and XML examples)
Jibbering
W3Schools AJAX Tutorial
Captain's AJAX Form Post/Get

Thanks,
Amit
May 4 '07 #3
acoder
16,027 Recognized Expert Moderator MVP
Those are tutorial links. Read through them and try them out. They should help you understand ajax. For your problem, create a server-side (C#) file which outputs the result of the function. Then make a request using XMLHttp calling that file with the correct parameters.

One other alternative is to use ASP.NET AJAX.

If you have problems, post your code here.
May 5 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

16
by: graham.reeds | last post by:
I am updating a website that uses a countdown script embedded on the page. When the page is served the var's are set to how long the countdown has left in minutes and seconds, but the rest of the...
6
by: Jim | last post by:
Group, How would I go about firing a JavaScript method from a C# method in the aspx code behind file? It seems as though this could not be done since JavaScript is executed from within the Web...
5
by: Mark | last post by:
Hi all, how do I open a javascript window from a code behind page? I was using Response.Write("<script language='javascript'>window.open('url','name','options');</script>") but now for some...
1
by: Paul D. Fox | last post by:
I'm trying to launch a Child Window from a hyperlink on a Datagrid and have it recieve multiple values from the Parent Window. Upon recieving the values in the Child Window, I need to access them...
4
by: Peter Bons | last post by:
Hi all, I have an asp.net page with a button that has a javascript onclick method attached to it to display a modal dialog like this: If reportHasParameters Then 'add client side onclick()...
3
by: Andrew Poulos | last post by:
I've been asked to add some additional code to HTML that get generated by a 3rd party program. Currently the code that gets generated already includes a window.onload = init; The program lets...
11
by: Adam Sandler | last post by:
Hello, Having an issue with JavaScript in my ASP.Net page. I use some COTS, which for all intents and purposes, simply makes a jpeg file and physically places it in a directory on the web...
4
by: Steve Hershoff | last post by:
Hi everyone, We have a javascript function we'd like to call from within a C# method in our code-behind file. The way it has worked historically is we'd call the method from a hyperlink, like...
22
by: Archanak | last post by:
Hi, I am using 2-level CSS Drop Down Menu in my perl/CGI program. here is the code. #!c:/perl/bin/perl.exe use CGI qw(:standard);
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
muto222
php
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.