Display Javascript Popup with Server side code

A quick and easy popup script that you can write in your asp.net server side code behind to show a javascript message window.

Simple add the below method in your code behind

public void Popup()

// Define the name and type of the client scripts on the page.
String csname1 = "PopupScript";

//String csname2 = "ButtonClickScript";
Type cstype = this.GetType();

// Get a ClientScriptManager reference from the Page class.
ClientScriptManager cs = Page.ClientScript;

// Check to see if the startup script is already registered.
if (!cs.IsStartupScriptRegistered(cstype, csname1))

String cstext1 = "alert('Common are u still copying ...!');";

cs.RegisterStartupScript(cstype, csname1, cstext1, true);


and call it as Popup();

Thats it!



This is a personal weblog. The opinions expressed here represent my own and not those of my employer or anyone else. Should you have any questions or concerns please e-mail me at sharepointprogrammingblogger@gmail.com .

Copyright (c) 2010 @ myshaepointwork.blogspot.com. All rights are reserved.Do Not Copy.

@ Learning SharePoint.com