473,396 Members | 2,011 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.

ClientScript.RegisterStartupScript

C
Hi,

On a click event of a button I do some validation.

If my validation is unsuccessful I display an alert to the user as below.

string message = "This is a test alert.";
ClientScript.RegisterStartupScript(typeof(Page), "alert", "<script
language=JavaScript>alert('" + (message) + "');</script>");

The alert gets displayed in FireFox but not in Internet Explorer.

Anyone know why?

Thanks.
Aug 1 '06 #1
9 49420
"C" <C@discussions.microsoft.comwrote in message
news:78**********************************@microsof t.com...
Hi,

On a click event of a button I do some validation.

If my validation is unsuccessful I display an alert to the user as below.

string message = "This is a test alert.";
ClientScript.RegisterStartupScript(typeof(Page), "alert", "<script
language=JavaScript>alert('" + (message) + "');</script>");

The alert gets displayed in FireFox but not in Internet Explorer.
Try this:

string strMessage = "This is a test alert."; // be careful of using
reserved words
ClientScript.RegisterStartupScript(this.GetType(), "alert",
"<script>alert('" + strMesssage + "');</script>");
Aug 1 '06 #2
C
Still does'nt work.

This is what I have
string message = "The record cannot can be Unlocked.";
ClientScript.RegisterStartupScript(this.GetType(), "alert",
"<script>alert('" + message + "');</script>");

I have no idea why it works in FireFox(v1.5.0.5) and not IE6.

"Mark Rae" wrote:
"C" <C@discussions.microsoft.comwrote in message
news:78**********************************@microsof t.com...
Hi,

On a click event of a button I do some validation.

If my validation is unsuccessful I display an alert to the user as below.

string message = "This is a test alert.";
ClientScript.RegisterStartupScript(typeof(Page), "alert", "<script
language=JavaScript>alert('" + (message) + "');</script>");

The alert gets displayed in FireFox but not in Internet Explorer.

Try this:

string strMessage = "This is a test alert."; // be careful of using
reserved words
ClientScript.RegisterStartupScript(this.GetType(), "alert",
"<script>alert('" + strMesssage + "');</script>");
Aug 1 '06 #3
"C" <C@discussions.microsoft.comwrote in message
news:09**********************************@microsof t.com...
I have no idea why it works in FireFox(v1.5.0.5) and not IE6.
Works fine for me in both browsers...
Aug 1 '06 #4
C
I will do some more digging. Maybe something with how my Page is composed.

Thanks.

"Mark Rae" wrote:
"C" <C@discussions.microsoft.comwrote in message
news:09**********************************@microsof t.com...
I have no idea why it works in FireFox(v1.5.0.5) and not IE6.

Works fine for me in both browsers...
Aug 1 '06 #5
"C" <C@discussions.microsoft.comwrote in message
news:29**********************************@microsof t.com...
>I will do some more digging. Maybe something with how my Page is composed.
When you do a View Source, what does the JavaScript look like? Is it
possible that it has word-wrapped?

I know that shouldn't be an issue, but I've seen similar effects before...
Aug 1 '06 #6
C
I just created a ASP.NET 2.0 Web Project with one page

Below is the entire codebehind. This still does'nt work in IE. I'm baffled.

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

namespace WebApplication3
{
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string message = "This is a test.";
ClientScript.RegisterStartupScript(typeof(Page), "alert",
"<script language=JavaScript>alert('" + message + "');</script>");

}
}
}

"Mark Rae" wrote:
"C" <C@discussions.microsoft.comwrote in message
news:09**********************************@microsof t.com...
I have no idea why it works in FireFox(v1.5.0.5) and not IE6.

Works fine for me in both browsers...
Aug 1 '06 #7
Worked for me in IE 6...
Did you check so that you have
<script language=JavaScript>alert('This is a test.');</script>
in your source?

Try entering javascript:alert('This is a test.'); in your address field
of the browser.

//Mats

C wrote:
I just created a ASP.NET 2.0 Web Project with one page

Below is the entire codebehind. This still does'nt work in IE. I'm baffled.

using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

namespace WebApplication3
{
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
string message = "This is a test.";
ClientScript.RegisterStartupScript(typeof(Page), "alert",
"<script language=JavaScript>alert('" + message + "');</script>");

}
}
}

"Mark Rae" wrote:
>"C" <C@discussions.microsoft.comwrote in message
news:09**********************************@microso ft.com...
>>I have no idea why it works in FireFox(v1.5.0.5) and not IE6.
Works fine for me in both browsers...
Aug 1 '06 #8
<Ma***@newsgroups.nospamwrote in message
news:OW**************@TK2MSFTNGP03.phx.gbl...
Try entering javascript:alert('This is a test.'); in your address field of
the browser.
Yes indeed, and the OP should also check that he has not disabled script
debugging and has enabled display a notification about every script error...
Aug 1 '06 #9
Hi,

C wrote:
I just created a ASP.NET 2.0 Web Project with one page

Below is the entire codebehind. This still does'nt work in IE. I'm baffled.
<snip>
string message = "This is a test.";
ClientScript.RegisterStartupScript(typeof(Page), "alert",
"<script language=JavaScript>alert('" + message + "');</script>");
<snip>

Additionally to what others suggested, the correct syntax for a script
tag is:

<script type="text/javascript">...</script>

The "language" attribute is deprecated. Beside, you should always
enclose attributes values in quote signs. I don't think that it's the
cause for the failure in IE, but who knows.

HTH,
Laurent
--
Laurent Bugnion, GalaSoft
Software engineering: http://www.galasoft-LB.ch
Private/Malaysia: http://mypage.bluewin.ch/lbugnion
Support children in Calcutta: http://www.calcutta-espoir.ch
Aug 2 '06 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: sck10 | last post by:
Hello, I have the following sub in a class in my "App_Code" directory. The script is for setting focus on a particular control, but I get the error, "Name ClientScript Not declared". Also, I am...
4
by: Alex Maghen | last post by:
When I do this in my page... ClientScript.RegisterStartupScript(this.GetType(), "SomeScript", "alert(\"Hi there\");"); it doesn't work AND when I view source, the alert() line is dumped into the...
3
by: sck10 | last post by:
Hello, I am trying to set the focus on an object using the following: However, I am getting the following error: The name Clientscript does not exist in the current context. protected void...
4
by: Jon Paal | last post by:
"Page.Clientscript" does not compile in assembly, with the error message "Reference to a non-shared member requires an object reference". ... what reference is it looking for ?????? class...
3
by: Wayne Deleersnyder | last post by:
Hi All, I'm trying to create a function that will cause a pop-up alert to appear if dates which were chosen from a drop-down list were invalid on a page. There's 4 dates, so there's the...
1
by: HockeyFan | last post by:
My function to get an alert box on the page isn't working. Instead it puts in the bottom section of the page: <script type="text/javascript"> <!-- This is a test// --> </script> The...
0
by: =?Utf-8?B?QW50b25pbw==?= | last post by:
Hello, everyone. I am trying to open a popup page to display some information but it is not working. Going through the code, no errors are generated. It goes to the end of the code but it does...
4
by: =?Utf-8?B?RHVuZTg4?= | last post by:
I've got some code that uses Page.ClientScript.RegisterStartupScript to call a javascript function from the Page_Load method in the code behind. The code works fine in IE but the javascript...
9
by: 0301102 | last post by:
I using following script in my project. Once click the button and there will open a pop up window. But "Page.ClientScript.RegisterStartupScript" script seem NOT working in update panel. After remove...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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?
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:
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
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
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
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.