|
Rank: Newbie Groups: Member
Joined: 10/9/2007 Posts: 5
|
The dialog does not display when wiring up a button to a user control that contains your dialog object. My User Control
Code: HTML/ASPX
<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="MyUserControl.ascx.cs" Inherits="MyUserControl" %>
<%@ Register TagPrefix="eo" NameSpace="EO.Web" Assembly="EO.Web" %>
<eo:Dialog
runat="server"
id="eodlg"
ControlSkinID="None"
Height="300px"
Width="300px"
BorderStyle="Solid"
CloseButtonUrl="00070101"
MinimizeButtonUrl="00070102"
AllowResize="True"
BorderWidth="1px"
ShadowColor="LightGray"
BorderColor="#335C88"
RestoreButtonUrl="00070103"
ShadowDepth="3"
ResizeImageUrl="00020014"
AcceptButton="btnOK"
AcceptButtonPostBack="true">
<HeaderStyleActive CssText="padding-right: 4px; padding-left: 4px; font-size: 11px; background-image: url(00070104); padding-bottom: 3px; padding-top: 3px; font-family: tahoma"></HeaderStyleActive>
<ContentStyleActive CssText="border-top: #335c88 1px solid; background-color: #e5f1fd"></ContentStyleActive>
<FooterStyleActive CssText="border-right: #22456a 1px solid; padding-right: 4px; border-top: #7d97b6 1px solid; padding-left: 4px; border-left-width: 1px; font-size: 11px; border-left-color: #728eb8; padding-bottom: 4px; color: white; padding-top: 4px; border-bottom: #22456a 1px solid; font-family: verdana"></FooterStyleActive>
<ContentTemplate>
Hello World!
</ContentTemplate>
<FooterTemplate>
<asp:Button
ID="btnOK"
runat="server"
Text="Ok" />
<asp:Button
ID="btnCancel"
runat="server"
Text="Cancel" />
</FooterTemplate>
</eo:Dialog>
Code: C#
public string ShowButton
{
get{ return eodlg.ShowButton; }
set { eodlg.ShowButton = value; }
}
Then i have a page that uses the user control.
Code: HTML/ASPX
<%@ Page Language="C#" MasterPageFile="Main.master" AutoEventWireup="true" CodeBehind="Config.aspx.cs" Inherits="Config" Title="Configuration" ValidateRequest="true" %>
<%@ Register TagPrefix="my" TagName="eocontrol" src="../UserControls/MyUserControl.ascx" %>
<asp:Content id="MyConfig" ContentPlaceHolderid="MyContentPlaceHolder" runat="server">
<asp:Button id="mybutton" runat="server" text="Click Me" />
<my:eocontrol id="eoctrl" runat="server" ShowButton="mybutton" />
</asp:Content>
When I click on the "Click Me" button, no dialog shows. WHY???
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,217
|
Hi, When the dialog looks for ShowButton, it only looks inside the same "NamingContainer" as the dialog. In your case, the NamingContainer is the user control itself, so when the dialog looks for ShowButton, it will only check within the user control. Whenever you need to show the dialog inside another NamingContainer, the easiest way is to use client side JavaScript. For example, instead of use a server side button, you can use the following HTML code:
Code: HTML/ASPX
<input type="button"
onclick="eo_GetObject('Dialog1').show();" value="Click Me" />
That should display the button regardless. Thanks
|
|
Rank: Newbie Groups: Member
Joined: 10/9/2007 Posts: 5
|
Is there a way to give it a temporary "NamingContainter" to look at instead? I can't go the javascript route as I need a dialog per intended function.
Example: Select Buildings dialog Select Users dialog etc...
OR better yet, is there a way to "perform default event registration" on a different naming container?
Example: If you added to your code...
Initialize(bool lookInParentContainer)
That would be ok, cause then i can set true in my control page load.
|
|
Rank: Administration Groups: Administration
Joined: 5/27/2007 Posts: 24,217
|
Hi, Unfortunately no. The purpose of NamingContainer (introduced by ASP.NET) is to isolate IDs into different scopes. I am not sure why using JavaScript would not work for your case, though. Theoretically there is no difference between using a server side button and JavaScript code because you can generates the JavaScript in your server side code. For example, instead of:
Code: HTML/ASPX
<asp:Button id="mybutton" runat="server" Text="Click Me" />
You can have:
Code: HTML/ASPX
<input type="button" id="mybutton" runat="server" value="Click Me" />
These two are pretty much equivalent. You can then set the onclick handler in code:
Code: C#
mybutton.Attributes["onclick"] = "eo_GetObject('Dialog1').show();";
Obviously you can replace "Dialog1" with whatever other value based on your code logic. And if necessary, you can change your implementation of "ShowButton" on your user control to call the above code. Let us know if this makes sense to you. Thanks
|
|
Rank: Newbie Groups: Member
Joined: 10/9/2007 Posts: 5
|
Yes, that makes sense. Thank you.
|
|