473,419 Members | 1,839 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,419 software developers and data experts.

Calling javascript function on form load event

Nikky
25
hello i am working on C#.net
i have a function on javascript

<script language="javascript">
function msg()
{
alert("my form")
}
</script>

In Web form i want to call this function .It is working with a button

Button1.Attributes.Add("onClick()","msg()");
but i want to perform it with forms load envent

pls reply soon.
Jul 12 '07 #1
5 42037
praveen2gupta
201 100+
hello i am working on C#.net
i have a function on javascript

<script language="javascript">
function msg()
{
alert("my form")
}
</script>

In Web form i want to call this function .It is working with a button

Button1.Attributes.Add("onClick()","msg()");
but i want to perform it with forms load envent

pls reply soon.

use following code in body of the HTML
Example
Expand|Select|Wrap|Line Numbers
  1. <body topmargin="0" leftmargin="0" onload="msg()">
  2.  
Jul 12 '07 #2
Nikky
25
use following code in body of the HTML
Example
Expand|Select|Wrap|Line Numbers
  1. <body topmargin="0" leftmargin="0" onload="msg()">
  2.  
thanX praveen2gupta

Yaa this code is working but i want MSG() function conditionally.
this code calls msg whenever form is loaded.but i m checking condition
if (i==0)
{
onLoad()
}
else
{
another condition
}
how can i call this function throught C#.net without using any click or any other event.
Jul 13 '07 #3
acoder
16,027 Expert Mod 8TB
thanX praveen2gupta

Yaa this code is working but i want MSG() function conditionally.
this code calls msg whenever form is loaded.but i m checking condition
if (i==0)
{
onLoad()
}
else
{
another condition
}
how can i call this function throught C#.net without using any click or any other event.
Put that condition statement in a function, then call that onload instead.
Jul 14 '07 #4
Nikky
25
Put that condition statement in a function, then call that onload instead.
How can i call me java script function on formload.

I am using this code

object value = Request.QueryString["val"].ToString();
if (value == "1")
{
Form.Attributes.Add("onLoad()","msg()" );
}

javascript;
function msg()
{
alert(U r in my frame);
}

I hav also trying

In my web page:
TextBox.Text=Request.QueryString["val"].ToString();

In my javascript page:
function msg()
{
if(TextBox1.Text=="1")
{
alert("u r in my frame");
}

}

In My HTML:
<body style="text-align: center" onload="msg()">

But this html code called at the initial loading of form.so that after this calling web page passing value on textbox so this function is also useless.. :(
Jul 16 '07 #5
acoder
16,027 Expert Mod 8TB
What is TextBox.Text? Is that the value of a text box? Use the proper Javascript way:
Expand|Select|Wrap|Line Numbers
  1. document.getElementById("textboxid").value
Jul 17 '07 #6

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

Similar topics

5
by: Krishna | last post by:
Hi all, Can i call my javascript functions from the web controls.Any appropriate site which will be tell more on this will be helpfull. Regards.., Krishna
4
by: Martin Feuersteiner | last post by:
Dear Group I'm using VB to write an aspnet application. I would like to call a javascript function from within a VB Sub or VB Function, is it possible? My code is something like this: VB...
6
by: Qwert | last post by:
Hello, I try to call the Close( ) method in the Load event of a Form, but it doesn't seem to work. Any idea why not? And how do I close a Form in it's own Load event? Private Sub...
3
by: Dennis | last post by:
I have the following code for showing a form: dim frm as new myForm frm.ShowDialog (The Form Load Event is fired then I hide the form using Me.Hide when the X in the UR corner is clicked). ...
2
by: lgbjr | last post by:
Hi All, I see that this topic was discussed back on august 23rd, but I didn't see a real answer. I have a VB.NET MDI app. A particular menu action on the MDI parent is to call an OpenFileDialog...
4
by: Vayse | last post by:
My Load event is running 3 times. I'm calling the form two different ways, and it always runs 3 times. As you can imagine, this makes the load time slow! Any help appreciated. Vayse Method...
1
by: Jason Richmeier | last post by:
I am experiencing some unexpected behavior with the Form Load event in a Windows application. Hopefully, someone can explain why this behavior is occurring. In my application, I have a form...
2
by: CSGeach | last post by:
Hello all In VB6, if you referred to a property or a some property of a control of an unloaded form, it caused a form_load, and fired the Form_Load event. I have a lot of code that depends on...
1
by: jmar93 | last post by:
I am using Access 2007. I am trying to write a form load event that runs a query and then if the query returns a value greater then "0" it needs to opens another form, if the query returns no value...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
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...

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.