473,396 Members | 1,765 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,396 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 42035
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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
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,...

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.