Click here to Skip to main content
15,889,651 members
Home / Discussions / ASP.NET
   

ASP.NET

 
GeneralRe: ASP.NET Gridview DataBound event retaining previous value Pin
Ibrahim Bello27-Aug-09 23:07
Ibrahim Bello27-Aug-09 23:07 
Questionmessagebox Pin
ankitjain111026-Aug-09 21:50
ankitjain111026-Aug-09 21:50 
AnswerRe: messagebox Pin
ankitjain111026-Aug-09 21:59
ankitjain111026-Aug-09 21:59 
GeneralRe: messagebox Pin
Coding C#26-Aug-09 22:22
Coding C#26-Aug-09 22:22 
GeneralRe: messagebox Pin
ankitjain111026-Aug-09 22:34
ankitjain111026-Aug-09 22:34 
GeneralRe: messagebox Pin
Coding C#26-Aug-09 22:39
Coding C#26-Aug-09 22:39 
GeneralRe: messagebox Pin
ankitjain111026-Aug-09 22:57
ankitjain111026-Aug-09 22:57 
GeneralRe: messagebox Pin
ankitjain111026-Aug-09 23:15
ankitjain111026-Aug-09 23:15 
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;
using System.Data.OleDb;
using System.Text.RegularExpressions;
using System.Text;

public class MessageBox : System.Web.UI.Page
{
private static Hashtable m_executingPages = new Hashtable();

private MessageBox(){}

public static void Show( string sMessage )
{
// If this is the first time a page has called this method then

if( !m_executingPages.Contains( HttpContext.Current.Handler ) )
{
// Attempt to cast HttpHandler as a Page.

Page executingPage = HttpContext.Current.Handler as Page;

if( executingPage != null )
{
// Create a Queue to hold one or more messages.

Queue messageQueue = new Queue();

// Add our message to the Queue

messageQueue.Enqueue( sMessage );

// Add our message queue to the hash table. Use our page reference

// (IHttpHandler) as the key.

m_executingPages.Add( HttpContext.Current.Handler, messageQueue );

// Wire up Unload event so that we can inject

// some JavaScript for the alerts.

executingPage.Unload += new EventHandler( ExecutingPage_Unload );
}
}
else
{
// If were here then the method has allready been

// called from the executing Page.

// We have allready created a message queue and stored a

// reference to it in our hastable.

Queue queue = (Queue) m_executingPages[ HttpContext.Current.Handler ];

// Add our message to the Queue

queue.Enqueue( sMessage );
}
}


// Our page has finished rendering so lets output the

// JavaScript to produce the alert's

private static void ExecutingPage_Unload(object sender, EventArgs e)
{
// Get our message queue from the hashtable

Queue queue = (Queue) m_executingPages[ HttpContext.Current.Handler ];

if( queue != null )
{
StringBuilder sb = new StringBuilder();

// How many messages have been registered?

int iMsgCount = queue.Count;

// Use StringBuilder to build up our client slide JavaScript.

//sb.Append( "<script language=""(JavaScript)""" );
sb.Append("<script language="'JavaScript'">");
//sb.Append("<script language=\"javascript\">");

// Loop round registered messages

string sMsg;
while( iMsgCount-- > 0 )
{
sMsg = (string) queue.Dequeue();
sMsg = sMsg.Replace( "\n", "\\n" );
sMsg = sMsg.Replace( "\"", "'" );
sb.Append( @"alert( """ + sMsg + @""" );" );
}

// Close our JS

sb.Append( @"</script>" );

// Were done, so remove our page reference from the hashtable

m_executingPages.Remove( HttpContext.Current.Handler );

// Write the JavaScript to the end of the response stream.

HttpContext.Current.Response.Write( sb.ToString() );

}
}
}

this is my code.its showing error.too many characters in character literal
QuestionHow to set CustomValidor for FileUpload Pin
shaik_mr26-Aug-09 21:27
shaik_mr26-Aug-09 21:27 
AnswerRe: How to set CustomValidor for FileUpload Pin
Ibrahim Bello27-Aug-09 1:20
Ibrahim Bello27-Aug-09 1:20 
QuestionAdding values to data gridview programmatically Pin
myinstincts26-Aug-09 21:26
myinstincts26-Aug-09 21:26 
Questionwhile using blank file , fileUpload doesn't work. Pin
Priyagdpl26-Aug-09 21:14
Priyagdpl26-Aug-09 21:14 
AnswerRe: while using blank file , fileUpload doesn't work. Pin
Arun Jacob26-Aug-09 21:33
Arun Jacob26-Aug-09 21:33 
GeneralRe: while using blank file , fileUpload doesn't work. Pin
Priyagdpl26-Aug-09 21:44
Priyagdpl26-Aug-09 21:44 
Questionthere is no source code available for the current location Pin
haleemasher26-Aug-09 21:13
haleemasher26-Aug-09 21:13 
AnswerRe: there is no source code available for the current location Pin
Arun Jacob26-Aug-09 21:22
Arun Jacob26-Aug-09 21:22 
AnswerRe: there is no source code available for the current location Pin
haleemasher26-Aug-09 21:27
haleemasher26-Aug-09 21:27 
Questionscripts in adrotator control? Pin
Member 387988126-Aug-09 21:06
Member 387988126-Aug-09 21:06 
AnswerRe: scripts in adrotator control? Pin
Arun Jacob26-Aug-09 21:10
Arun Jacob26-Aug-09 21:10 
Questionscripts in adrotator control Pin
Member 387988126-Aug-09 21:05
Member 387988126-Aug-09 21:05 
AnswerRe: scripts in adrotator control Pin
Abhishek Sur26-Aug-09 21:57
professionalAbhishek Sur26-Aug-09 21:57 
QuestionHow to Avoid Session hijacking Pin
IsamilAmeerAli26-Aug-09 21:02
IsamilAmeerAli26-Aug-09 21:02 
AnswerRe: How to Avoid Session hijacking Pin
Abhishek Sur26-Aug-09 21:43
professionalAbhishek Sur26-Aug-09 21:43 
QuestionRe: How to Avoid Session hijacking Pin
IsamilAmeerAli26-Aug-09 22:53
IsamilAmeerAli26-Aug-09 22:53 
Questionparameters to Stored procedure in ASP.net Pin
Ramakrishna GS26-Aug-09 20:54
Ramakrishna GS26-Aug-09 20:54 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.