473,597 Members | 2,190 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

ClientScript.Re gisterStartupSc ript 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_Cr eate(ref System.Web.UI.P age
thePage,
Type thisType,
string strMessage,
string strKey)
{
System.Web.UI.C lientScriptMana ger ClientScript =
thePage.ClientS cript;
string strScript = "alert('" + strMessage + "');";
if (!ClientScript. IsStartupScript Registered(this Type,
strKey))
{
ClientScript.Re gisterStartupSc ript(thisType, strKey,
strMessage, true);
}
}

and I call this function as follows:
System.Web.UI.P age pg = this;
Bus.UtilStatic. MessageAlert_Cr eate(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 6382
Well change
ClientScript.Re gisterStartupSc ript(thisType, strKey, strMessage, true);

to
ClientScript.Re gisterStartupSc ript(thisType, strKey, strScript , true);

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

George.

"HockeyFan" <le**********@g mail.comwrote in message
news:11******** **************@ 57g2000hsv.goog legroups.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_Cr eate(ref System.Web.UI.P age
thePage,
Type thisType,
string strMessage,
string strKey)
{
System.Web.UI.C lientScriptMana ger ClientScript =
thePage.ClientS cript;
string strScript = "alert('" + strMessage + "');";
if (!ClientScript. IsStartupScript Registered(this Type,
strKey))
{
ClientScript.Re gisterStartupSc ript(thisType, strKey,
strMessage, true);
}
}

and I call this function as follows:
System.Web.UI.P age pg = this;
Bus.UtilStatic. MessageAlert_Cr eate(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
4434
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 using MasterPages. How do I use "ClientScript.RegisterStartupScript" in a class? Public Shared Sub SetFocusControl(ByVal FocusControl As Control) Dim Script As New System.Text.StringBuilder Dim ClientID As String = FocusControl.ClientID
1
5635
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
5618
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 SetFocusControl(Control FocusControl) { StringBuilder script = new StringBuilder();
9
49442
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."; ClientScript.RegisterStartupScript(typeof(Page), "alert", "<script language=JavaScript>alert('" + (message) + "');</script>");
4
3314
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 class1 public sub showimg() Dim Response As HttpResponse = HttpContext.Current.Response Dim theImage As New object
3
3947
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 possibility of 4 errors at once. I'd like to pop-up all the errors at once, so the user can correct all the errors at once. My issue is format. I'd like a message something like... ERROR: Acquired Date Invalid - only 28 days in February for year
0
6529
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 not open the page. Am I missing something? It's VS 2005. Thanks, protected void lnk_Comments_Click(object sender, EventArgs e) {
9
42751
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 Update panel and it is working properly. Any solution? Page.ClientScript.RegisterStartupScript(Me.GetType(), "openpopup", "window.open('" & "child.aspx" & "','ChildWindow','height = 520, width = 730,status=no,location=no,directories=no, resizable =...
6
1850
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 script executes again even though the button hasn't been clicked. Here's the sub - the button is a standard ASP button with no frills...
0
7970
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
7887
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8274
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8381
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8036
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8259
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6695
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
5434
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
1494
muto222
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.