Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > Problem with alert message

Reply
Thread Tools

Problem with alert message

 
 
Vivian
Guest
Posts: n/a
 
      06-28-2006
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);
}


 
Reply With Quote
 
 
 
 
Vadivel Kumar
Guest
Posts: n/a
 
      06-28-2006
This is wrong approach. It wont show the alert message.

Basically, the RegisterClientScriptBlock method just registers the
script while rendering the page. In this case, first time when the
webform loads it won't display the message. But, if you refresh the page
again by pressing f5 it will display the alert box.

Let me know if you are looking for the same or you want something else.

-
Vadivel Kumar
http://vadivelk.net

Vivian wrote:
> 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);
> }
>
>

 
Reply With Quote
 
 
 
 
subhashiniRuckmani subhashiniRuckmani is offline
Junior Member
Join Date: Jul 2007
Posts: 3
 
      07-04-2007
Hai friends

I am very new to .net. I want to display the alert message from the class file.
This class file is called in the Default.cs. can any one help me in this.

Thanks in advance.
 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Alert..General Alert?..New Discovery?. =?Utf-8?B?U3BhbW1lcipLaWxsZXI=?= Wireless Networking 0 07-24-2007 03:36 PM
on click in popup window throws alert : need to avoid alert of postdata Ganesh ASP .Net 0 06-29-2007 06:51 AM
How to create a form Alert - Not using Alert Boxes Mersh Java 0 03-13-2007 04:14 PM
Javascript alert message problem Tony Girgenti ASP .Net 22 10-16-2006 09:11 PM
ALERT: Virus Scam Alert! Toronto Garage Door Company Computer Support 1 11-18-2003 04:16 PM



Advertisments
 



1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57