开发者

Application wide Modalpopupextender

开发者 https://www.devze.com 2023-03-27 23:57 出处:网络
I\'m trying to build a modalpopupextender, along with a panel and content, and need to make it application-wide. I am thinking about creating it on the Masterpage, so it\'s accessible on all pages, bu

I'm trying to build a modalpopupextender, along with a panel and content, and need to make it application-wide. I am thinking about creating it on the Masterpage, so it's accessible on all pages, but I need the content inside the panel (anything that I may need to add there) to be visible and editable from outsite the masterpage. For now, I'm working on this, but haven't figured out how to make it accessible to other pages and classes, and so would like to have some help on it.

Basically, what I want is to work more on the idea in a near future in order to make something consistent to be used on any web application, and to be fully customizable. What I'm having trouble is with "basics", like making it accessible to the application, allow customization of some controls inside the panel from both server and client sides, and will improve everything from there.

I have tried creating a user control for it, but didn't seem to work. I'm not an expert on asp.net (few years of experience), and even less on ajax, so any help is appreciated. Please let me know if anybody have any questions.

EDIT: I have now succeeded somehow creating the moodal within a user control and it's almost done. At this moment, there are 2 issues I couldn't fix:

  1. The damn flickering that happens on Firefox 3.5 (Corporate version, can't touch this). Ocasionally during page load (Somewhere near Page_Init or Page_PreInit events, not sure), the modals I have blink quickly on the screen, only when a postback happens. I have already done some workaround, like setting style display:none, but the issue remains. Need some help on the matter.
  2. I need to have a modal that have 2 behaviors, like windows popups. One is information, likee only showing the message with some buttons, and the other is question. For questions, I'll need to开发者_StackOverflow社区 use the ConfirmButtonExtender, and so would need to tell this confirm extender and the modal that an external button (Means a button that isn't within the user control, and by that means it's outside the same UpdatePanel as the confirm extender and modal extender) will be their TargetControlID. For now, I couldn't solve this, so I thought about creating a button inside the UC and UpdatePanel that will always be the TargetControlID. When the popup is informational, it will work as a dummy hidden button (information messages are called on server-side through methods), and when it's a question, it will receive the response. The method to be executed by the button will be set through a delegate, and therefore any method may be run when it's clicked and the Yes button on the modal is pressed (It's not ready yet, and I'm not sure it will work, or even if it's a good idea). Any thoughts on this second option is appreciated.


It's easy for elements on the masterpage to be visible and editable from outsite the masterpage.

In this example the masterpage has a label that you want to read/write from other pages

<asp:Label ID="lblSubTitle" runat="server" Text="sub title"></asp:Label>

In the codefile for the masterpage, create a property for the subtitle:

public partial class MainMasterPage : System.Web.UI.MasterPage
{
    public string SubTitle
    {
        get
        {
            return lblSubTitle.Text;
        }
        set
        {
            lblSubTitle.Text = value;
        }
    }
}

Then any page that uses this masterpage as its MasterPageFile can find the subtitle property and read or write it.

// get a reference to the masterpage
MainMasterPage master = (MainMasterPage)Master;

//set it to the value you want.
master.SubTitle = "Custom sub title";


I have solved the issue and created a user control containing the modalpopup for showing customized messages. Many aspects are public, so it allows high customization, and the modal and it's customized buttons work like a charm. I still have a problem regarding the flickering, but it's for another question.

0

精彩评论

暂无评论...
验证码 换一张
取 消