473,396 Members | 1,785 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.

Problem with alert message

I've created a web page with ASP .NET and C#. Say my aspx filename is
"WebForm1.aspx", I have created another C# file named "Details.cs".

My problem is I want to prompt an alert message from both WebForm1.cs and
Details.cs, WebForm1.cs works fine, but no message can be shown from
Details.cs. The two files are in the same namespace with different class.
I've referred to WebForm1.cs.

The following is my code :

Namespace = "Test"

WebForm1.cs
===========
inside class WebForm1

public void PrintMsg(string key, string msg)
{
this.Page.RegisterClientScriptBlock(key, "<script
type='text/javascript'>alert('" + msg + "');</script>");
}

Details.cs
=======
inside class detailscode

private void PrintMessage(string key, string msg)
{
Test.WebForm1 oForm = new Test.WebForm1();
oForm.PrintMsg(key, msg);
}

Jun 28 '06 #1
1 3663
Hi,

How you instantiate Details?

remember that the client is the browser, so only the page being executed is
the one that is generating the output.

You could change the code like this:

public void PrintMsg(string key, string msg, Page outputPage)
{
outputPage.RegisterClientScriptBlock(key, "<script
type='text/javascript'>alert('" + msg + "');</script>");
}

You would have to pass a reference to the current page (this) to the
instance of detailscode

Another possibility is using HttpContext. you would have access to the
Response object but you cannot use RegisterClientScriptBlock , you would
have to use Response.Write
In anyway I think you are confused about how a web app works. maybe if you
post more details about what you want to do and your current structure we
can help you further.
--
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Vivian" <wk****@hotmail.com> wrote in message
news:Ow**************@TK2MSFTNGP02.phx.gbl...
I've created a web page with ASP .NET and C#. Say my aspx filename is
"WebForm1.aspx", I have created another C# file named "Details.cs".

My problem is I want to prompt an alert message from both WebForm1.cs and
Details.cs, WebForm1.cs works fine, but no message can be shown from
Details.cs. The two files are in the same namespace with different class.
I've referred to WebForm1.cs.

The following is my code :

Namespace = "Test"

WebForm1.cs
===========
inside class WebForm1

public void PrintMsg(string key, string msg)
{
this.Page.RegisterClientScriptBlock(key, "<script
type='text/javascript'>alert('" + msg + "');</script>");
}

Details.cs
=======
inside class detailscode

private void PrintMessage(string key, string msg)
{
Test.WebForm1 oForm = new Test.WebForm1();
oForm.PrintMsg(key, msg);
}

Jun 28 '06 #2

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

Similar topics

4
by: Nitin | last post by:
Hi I have created function to check date and time. at the time of execution, if date is left empty the function returns the error message but then the focus goes to next field. Next filed is for...
3
by: dgmoore | last post by:
Hello - I'm having trouble with JavaScript alerts in an imagemap. The mapped areas are cells in a table, and the alerts display info related to the cell that is clicked. The problem is that,...
9
by: Wayne Wengert | last post by:
I am attempting to incorporate some techniques I found in an MSDN article into one of my aspx pages. It basically adds a new class that Inherits from the System.Web.UI.Page and includes some new...
3
by: Ersin Gençtürk | last post by:
hi, I wrote a function like this : public static void Alert(string message){ message=message.Replace("'","\'"); message=message.Replace("\n","\\n"); ...
7
by: Ankit Aneja | last post by:
I put the code for url rewrite in my Application_BeginRequest on global.ascx some .aspx pages are in root ,some in folder named admin and some in folder named user aspx pages which are in user...
1
by: Vivian | last post by:
I've created a web page with ASP .NET and C#. Say my aspx filename is "WebForm1.aspx", I have created another C# file named "Details.cs". My problem is I want to prompt an alert message from both...
22
by: Tony Girgenti | last post by:
Hello. I'm developing and testing a web application using VS.NET 2003, VB, .NET Framework 1.1.4322, ASP.NET 1.1.4322 and IIS5.1 on a WIN XP Pro, SP2 computer. I'm using a web form. Using...
9
by: tshad | last post by:
This was posted before but the message got messed up (all NLs were stripped out for some reason). I have 2 labels that hold the name of different images on my .aspx page. <asp:Label ID="Logo"...
0
by: LTCCTL | last post by:
hi all, I have an application to send and recieve an SMS but my application is not catching the incoming message. can anyone tell what's wrong with the following code: import...
2
by: swethak | last post by:
Hi, I am getting the problem the problem with google map in Internet Explorer. This map worked fine in mozilla . When i opened the same map in Internet Explorer i am getting the error...
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
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...

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.