The Artima Developer Community
Sponsored Link

.NET Buzz Forum
JavaScript Alert von CodeBehind-File aufrufen

0 replies on 1 page.

Welcome Guest
  Sign In

Go back to the topic listing  Back to Topic List Click to reply to this topic  Reply to this Topic Click to search messages in this forum  Search Forum Click for a threaded view of the topic  Threaded View   
Previous Topic   Next Topic
Flat View: This topic has 0 replies on 1 page
-

Posts: 1524
Nickname: nitronic
Registered: Jul, 2006

Norbert Eder works as a software architect.
JavaScript Alert von CodeBehind-File aufrufen Posted: Feb 10, 2007 1:19 PM
Reply to this message Reply

This post originated from an RSS feed registered with .NET Buzz by -.
Original Post: JavaScript Alert von CodeBehind-File aufrufen
Feed Title: Norbert Eder - Living .NET
Feed URL: http://feeds.feedburner.com/NorbertEder-Livingnet
Feed Description: Copyright (c)2005, 2006 by Norbert Eder
Latest .NET Buzz Posts
Latest .NET Buzz Posts by -
Latest Posts From Norbert Eder - Living .NET

Advertisement
In vielen Foren wird oft die Frage gestellt, wie denn aus beispielsweise C# heraus eine MessageBox im Web angezeigt werden kann.

Folgende Klasse zeigt die Verwendung:

public static class Alert 
{ 
    public static void Show(string message) 
    { 
        string repMessage = message.Replace("'", "'"); 
        string script = " 
            + repMessage + "');"; 
        
        Page page = HttpContext.Current.CurrentHandler as Page; 
        
        if (page != null 
            && !page.ClientScript.IsClientScriptBlockRegistered("alert")) 
        { 
            page.ClientScript.RegisterClientScriptBlock(typeof(Alert), 
                "alert", script); 
        } 
    } 
}

Unsere Funktionalit��t kann nun von jeder beliebigen Stelle mit

Alert.Show("Dies ist ein Test");

aufgerufen werden.

Read: JavaScript Alert von CodeBehind-File aufrufen

Topic: Aspect Oriented Programming Previous Topic   Next Topic Topic: Cocoa vs Swing vs .NET: invoking a method on the main GUI thread

Sponsored Links



Google
  Web Artima.com   

Copyright © 1996-2019 Artima, Inc. All Rights Reserved. - Privacy Policy - Terms of Use