473,396 Members | 1,758 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 problem

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 function is:
public static void MessageAlert_Create(ref System.Web.UI.Page
thePage,
Type thisType,
string strMessage,
string strKey)
{
System.Web.UI.ClientScriptManager ClientScript =
thePage.ClientScript;
string strScript = "alert('" + strMessage + "');";
if (!ClientScript.IsStartupScriptRegistered(thisType,
strKey))
{
ClientScript.RegisterStartupScript(thisType, strKey,
strMessage, true);
}
}

and I call this function as follows:
System.Web.UI.Page pg = this;
Bus.UtilStatic.MessageAlert_Create(ref pg,
this.GetType(), "This is a test", "Tester");
any ideas how to get the alert box to show up?

Jul 20 '07 #1
1 6337
Well change
ClientScript.RegisterStartupScript(thisType, strKey, strMessage, true);

to
ClientScript.RegisterStartupScript(thisType, strKey, strScript , true);

notice the difference.
strScript instead of strMessage in your code.

George.

"HockeyFan" <le**********@gmail.comwrote in message
news:11**********************@57g2000hsv.googlegro ups.com...
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 function is:
public static void MessageAlert_Create(ref System.Web.UI.Page
thePage,
Type thisType,
string strMessage,
string strKey)
{
System.Web.UI.ClientScriptManager ClientScript =
thePage.ClientScript;
string strScript = "alert('" + strMessage + "');";
if (!ClientScript.IsStartupScriptRegistered(thisType,
strKey))
{
ClientScript.RegisterStartupScript(thisType, strKey,
strMessage, true);
}
}

and I call this function as follows:
System.Web.UI.Page pg = this;
Bus.UtilStatic.MessageAlert_Create(ref pg,
this.GetType(), "This is a test", "Tester");
any ideas how to get the alert box to show up?

Jul 20 '07 #2

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...
1
by: mike | last post by:
i'd like to use ClientScript.RegisterStartupScript it belongs to page class but i wanna use this how can i do?
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...
9
by: C | last post by:
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.";...
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...
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...
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...
6
by: Danielle | last post by:
Greetings all - I am working on a vb .NET asp web application. I have a button that opens a new page when clicked. It works fine; the problem is when the user refreshes the original page, the...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
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.