Blog Stats
  • Posts - 34
  • Articles - 1
  • Comments - 3
  • Trackbacks - 6

 

Modal Dialog in ASP.NET 2.0 master content page, nothing new yet discovered

Creating a modal dialog popup is common in most enterprise web application especially to display lookup tables values and return back the values from the lookup table to its parent page. In ASP.NET 1.1 and also ASP.NET 2.0 I created  the lookup table by using Javascript showDialog method or just using window.open methods. But how about if I want to open and return the modal dialog value from master page content. We cannot ad the inside the content page. The trick is to add the javascript function into one .js file and refer the external .js file is master page itself and let it inherit to all the content page. This techniques implemented by TimeTracker starter kits. But it takes lots of efforts. The steps is to create the external javascript script file, refer the file in master page, and call the javascript function in contentplaceholder page. The steps seems simple, but for me, its tedius, unless we create a generic script so that it can be reusable each time we want to call a modal dialog. 

 

here's example of javascript function:

function OpenPopup (pageUrl, controlID, isPostBack){

popUp=window.open(pageUrl+'?controlID='+controlID+'&isPostBack='+ isPostBack,'popupcal', 'width=250,height=300,left=200,top=250');

}

we can add the javascript function using attributes.add method

Button1.Attributes.Add("OnClick", "OpenPopupPage(controlID, isPostBack, windowSetting);");

Until next time and Happy holiday.

[update 22/12]

I think this article is a good solution to the web modal dialog: http://weblogs.asp.net/jezell/archive/2003/08/26/25450.aspx


Feedback

# re: Modal Dialog in ASP.NET 2.0 master content page, nothing new yet discovered

Gravatar use div within the page where you need to show dialog. The DIV will contain the elements fo rthe dialog and you can very well show and hide it. You can also then pass values easily. 1/17/2006 9:16 PM | Anup

# re: Modal Dialog in ASP.NET 2.0 master content page, nothing new yet discovered

Gravatar You could also let your modal inherit from the Master... but put all the contents of the Master (except for the content placeholder) in separate panels. Then in your modal page, declare your master's panels through type casting, and set their visibilities to "false". The below was copied from my modal:

Panel myLogoPanel = (Panel)(Master.FindControl("logoPanel"));
myLogoPanel.Visible = false; 4/18/2006 1:21 PM | Nila

# re: Modal Dialog in ASP.NET 2.0 master content page, nothing new yet discovered

Gravatar Great work done. I really need it 7/26/2009 5:25 AM | Qasim Ali

Post a comment





 

 

 

Copyright © Rasyadi