ラベル popup の投稿を表示しています。 すべての投稿を表示
ラベル popup の投稿を表示しています。 すべての投稿を表示

2012年3月28日水曜日

Resizable Modal Popups?

I'm trying to make a modal popup be resizable. I've tried to combine the ModalPopupExtender with the ResizableControlExtender. Both are associated with the same panel.

It kinda works, but not correctly. When the popup appears, the resize graphic shows up on the left hand corner of the panel. After I click on the resize graphic it then will expand to the size of the modal window. In addition if the contents of the panel have to scroll (as a result of the resizing) the scrollbars mess up the positioning of the resize graphic.

I also had to turn off the drop shadow since it was not resizing with the panel.

Gerry

I think this is a definite nice to have especially if the popup is has a lot of form controls and you would like people to resize and/or have scrolling turned on. Please open awork item for this and we look into fixing this. The solution may not be very straightforward given that you want it to have the dropshadow and the drag in addition to the resize so the modalpopup code itself may need to change. Thanks!


It should work just fine Without the drop shadow. You can hook up the resizable extender to the modal panel and get things working for you.

The drop-shadow is not important to me. I will go ahead and enter the item.

Thanks,
Gerry


I haven't used the modal popup yet but I suspect that it is much like the popup extender. To get the shadow to stick with the control I had to add another panel that contained the popup container panel. I then hooked the resizable extender to that outer panel.

Again I haven't attempted it yet with modal. Here is a link to the code in the forum where I posted my solution.

http://forums.asp.net/t/1082450.aspx

Larry Aultman


I was not able to make the resizable extender work with the ModalPopup extender. I am sure that the source code could be modified to make it work however there is another solution that works very well and yields the same results: a drag-able, resizable, popup modal dialog. I am providing all the code below. You will need an "overlay" image that will provide the user screen "gray-out" effect. You also need very specific CSS styles and then you need the aspx and codebehind. I have included all source necessary, except the overlay.png file.

In my experience, most of the time that I would need a modal popup I need to get something that is bound for the server. Rarely do I need a popup that collects information when it isn't sent back. So this version's purpose is to collect data in a modal popup and send it all back to the server where the magic is done. Rather than use complex javascript to raise events back to the server I chose to use the extenders to handle the display and use AJAX update panels to handle the server. It all works very smoothly. I get the slick action of the client side and the AJAX posting.

Larry Aultman

I created my overlay.png file using Microsoft Expression. Very easy, make a new document with a size of say 32x32 pixels. Use the rectangle tool and draw a box removing the border and filling it with a soft color. I used a color that works well with my website. In the properties window set the Opacity to 50 (which is 50% transparent). Then export the image in PNG format. Drop this into your project folder. In the style sheet you will see my reference to the "overlay.png". NOTE: paths to files are relative to the style sheet's location NOT to the root of the site. I suggest that you put your style sheet in the root until you get everything working. Then you can move things around.

Next create a new aspx page with a codebehind page defined. Add a link in the "head" section to your style sheet something like:

<linkhref="pageStyles.css"rel="stylesheet"type="text/css"/>

Next place the following code in between the div tags in the new page.

<asp:scriptmanagerID="scriptmanager1"EnablePartialRendering="true"runat="server"></asp:scriptmanager>
<asp:UpdatePanelid="UpdatePanel1"runat="server">
<ContentTemplate>
<asp:ButtonID="btnShowDialog"runat="server"Text="Show Modal Popup"onclick="btnShowDialog_Click"/><br/>
<asp:LabelID="lbLoginMsg"runat="server"Text="User Not logged In"></asp:Label>
<divid="popupContainer1"class="popupContainer">
<asp:Panelid="popupPanel1"runat="server"Visible="false"CssClass="overlay">
<asp:Panelid="dragControl1"runat="server"CssClass="dragControl">
<asp:Panelid="popupClientArea1"runat="server"CssClass="popupClientArea">
<asp:Panelid="dragPanel1"runat="server"CssClass="dragMePanel">
<divid="dragMe1"class="dragMe"> Login </div>
</asp:Panel>
<asp:Panelid="popupContent1"runat="server"CssClass="popupContent">
<divid="popupBuffer1"class="popupBuffer">
User Name:<asp:TextBoxID="TextBox1"runat="server"></asp:TextBox><br/>
Password :<asp:TextBoxID="TextBox2"runat="server"></asp:TextBox><br/><br/>
<center>
<asp:ButtonID="btnLogin"runat="server"Text="Login"onclick="btnLogin_Click"/>
<asp:ButtonID="btnCancel"runat="server"Text="Cancel"onclick="btnCancel_Click"/>
</center>
</div>
</asp:Panel>
</asp:Panel>
</asp:Panel>
</asp:Panel>
<cc1:DragPanelExtenderid="DragPanelExtender1"runat="server"DragHandleID="dragPanel1"TargetControlID="dragControl1">
</cc1:DragPanelExtender>
<cc1:DropShadowExtenderid="DropShadowExtender1"runat="server"TargetControlID="popupClientArea1"Opacity="1"TrackPosition="True">
</cc1:DropShadowExtender>
<cc1:ResizableControlExtenderid="ResizableControlExtender1"runat="server"HandleCssClass="handleResizer"HandleOffsetX="2"HandleOffsetY="2"MinimumHeight="200"MinimumWidth="100"ResizableCssClass="resizingImage"TargetControlID="popupClientArea1">
</cc1:ResizableControlExtender>
</div>
</ContentTemplate>
</asp:UpdatePanel>

Now you need the codebehind:

protectedvoid Page_Load(object sender,EventArgs e)
{
this.ResizableControlExtender1.MinimumHeight = 200;//set inital size of the popup
this.ResizableControlExtender1.MinimumWidth = 300;//set inital size of the popup
}

protectedvoid btnShowDialog_Click(object sender,EventArgs e)
{
this.lbLoginMsg.Text ="User Not Logged In";
if (popupPanel1.Visible ==false)
popupPanel1.Visible =true;
}

protectedvoid btnCancel_Click(object sender,EventArgs e)
{
this.lbLoginMsg.Text ="User Canceled Login";
popupPanel1.Visible =false;
}

protectedvoid btnLogin_Click(object sender,EventArgs e)
{
this.lbLoginMsg.Text ="User: " + TextBox1.Text +" Password: " + TextBox2.Text;
popupPanel1.Visible =false;
}

Finally you need the CSS styles that make things happen.

/* Popup AJAX windows */

.popupControl

{

/*visibility:hidden;*/

}

.popupWin/* holds the entire popup window and its basic look.*/

{

background-color:Transparent;

font-family:"trebuchet MS",tahoma,verdana,arial,helvetica,sans-serif;

color:#838F86;

clear:both;

font-size:1em;

padding:10px;

height:50em;

width:50em;

min-width:20em;

min-height:20em;

}

.popupContainer/* holds the entire popup window and its basic look.*/

{

background-color:Transparent;

font-family:"trebuchet MS",tahoma,verdana,arial,helvetica,sans-serif;

color:#838F86;

clear:both;

float:left;

font-size:1em;

padding:10px;

height:50em;

width:50em;

min-width:20em;

min-height:20em;

}

.overlay

{

position:absolute;

left:0px;

top:0px;

width:100%;

height:100%;

text-align:center;

z-index:10;

background-image:url('images/overlay.png');/* relative to the style sheet file location */

background-repeat:repeat;

}

.dragControl

{

background-color:white;

z-index:100;

}

.popupClientArea/* provides the painting surface for the popup window */

{

background-color:#ffffff;

border:solid1px#445447;

overflow:hidden;

width:25em;

z-index:200;

}

.popupContent/* all content in the popup will be contained here */

{

background-color:Transparent;

overflow:auto;

text-align:left;

height:auto;

width:100%;

}

.popupBuffer/* this div provides a padding buffer from the edge so the content doesn't come flush with the edge */

{

padding:.3em;

}

.dragMePanel/* this provides the top edge that is the dragable area */

{

background-image:url('images/bg_nav.png');/* relative to the style sheet file location */

background-repeat:repeat-x;

cursor:move;

width:100%;

height:20px;

z-index:210;

}

.dragMe/* any text that might be shown in the drag area */

{

color:#ffffff;

text-align:center;

font-size:.8em;

font-family:"trebuchet MS",tahoma,verdana,arial,helvetica,sans-serif;

font-weight:normal;

}

.handleResizer

{

width:15px;

height:16px;

background-image:url('images/HandleHand.png');

overflow:hidden;

cursor:se-resize;

}

.resizingImage

{

border-style:solid;

border-width:2px;

border-color:#445447;

padding:0px;

}

2012年3月21日水曜日

RoundedCorners used with other controls

Has anyone had any luck in using the RoundedCorners control with any other controls, such as HoverMenu, Popup, etc?

PopupControl calendar in ajax beta 2 toolkit:

<asp:Panel ID="Panel1" runat="server" CssClass="popupControl"> <asp:UpdatePanel ID="UpdatePanel1" runat="server"> <ContentTemplate> <center> <asp:Panel ID="Panelx" runat="server" Width="160px" CssClass="xroundedPanel"> <asp:Calendar ID="Calendar1" runat="server" BackColor="White" BorderColor="#999999" CellPadding="1" DayNameFormat="Shortest" Font-Names="Verdana" Font-Size="8pt" ForeColor="Black" Width="160px" OnSelectionChanged="Calendar1_SelectionChanged"> <SelectedDayStyle BackColor="#666666" Font-Bold="True" ForeColor="White" /> <TodayDayStyle BackColor="#CCCCCC" ForeColor="Black" /> <SelectorStyle BackColor="#CCCCCC" /> <WeekendDayStyle BackColor="#FFFFCC" /> <OtherMonthDayStyle ForeColor="#808080" /> <NextPrevStyle VerticalAlign="Bottom" /> <DayHeaderStyle BackColor="#CCCCCC" Font-Bold="True" Font-Size="7pt" /> <TitleStyle BackColor="#999999" Font-Size="7pt" BorderColor="Black" Font-Bold="True" /> </asp:Calendar> </asp:Panel> </center> <ajaxToolkit:RoundedCornersExtender ID="RoundedCornersExtender1" BehaviorID="RoundedCornersBehavior1" runat="server" TargetControlID="Panelx" Radius="4" /> </ContentTemplate> </asp:UpdatePanel> </asp:Panel>

StyleSheetcss:

/* Rounded Corners*/.xroundedPanel{width:160px;background-color:#999999;}.roundedPanel{width:300px;background-color:#5377A9;color:white;font-weight:bold;}


PopupControl reminder message in ajax beta 2 toolkit:

StyleSheet.css:

/*Popup Control*/.ypopupControl{background:transparent;position:absolute;visibility:hidden;}.popupControl{background-color:White;position:absolute;visibility:hidden;}/* Rounded Corners*/.yroundedPanel{width:200px;background-color:#849EC0;}.xroundedPanel{width:160px;background-color:#999999;}.roundedPanel{width:300px;background-color:#5377A9;color:white;font-weight:bold;}

PopupControl.aspx:

<asp:Panel ID="Panel2" runat="server" CssClass="ypopupControl"> <div style="border:0px outset white; width:200px; font-weight: bold;"> <asp:UpdatePanel ID="UpdatePanel2" runat="server"> <ContentTemplate> <asp:Panel ID="Panely" runat="server" Width="200px" CssClass="yroundedPanel"> <asp:RadioButtonList ID="RadioButtonList1" runat="server" OnSelectedIndexChanged="RadioButtonList1_SelectedIndexChanged" AutoPostBack="true"> <asp:ListItem Text=" Walk dog"></asp:ListItem> <asp:ListItem Text=" Feed dog"></asp:ListItem> <asp:ListItem Text=" Feed cat"></asp:ListItem> <asp:ListItem Text=" Feed fish"></asp:ListItem> <asp:ListItem Text=" Cancel" Value=""></asp:ListItem> </asp:RadioButtonList> </asp:Panel> <ajaxToolkit:RoundedCornersExtender ID="RoundedCornersExtender2" BehaviorID="RoundedCornersBehavior1" runat="server" TargetControlID="Panely" Radius="8" /> </ContentTemplate> </asp:UpdatePanel> </div> </asp:Panel>

Rounded Corners applied to Hovermenu Demonstration in ajax beta 2 toolkit.

In this example, the rightmost Update/Cancel hover has rounded corners.

So far, a design/coding issue results in an unsatisfactory solution for the leftmost Edit/Delete hover. To be taken-up in a different thread.

StyleSheet.css:

 
/*Hover Menu*/.popupMenua {/*for roundedcorners-hovermenu demo*/position:absolute;visibility:hidden;background-color:red;background:transparent;/*hide corners*/opacity:.9;filter: alpha(opacity=90);}.popupMenu {position:absolute;visibility:hidden;background-color:#F5F7F8;opacity:.9;filter: alpha(opacity=90);}.popupHover { position:relative;/*fix IE cold-spot between hover & grid*/background-image:url(images/header-opened.png);background-repeat:repeat-x;background-position:left top;background-color:#F5F7F8;}/* Rounded Corners*/.ahovermenuroundedPanel/*for roundedcorners-hovermenu demo*/{width:80px;background-color:orange;/*for demo clarity*/}

HoverMenu.aspx:

<asp:UpdatePanel ID="up1" runat="server"> <ContentTemplate> <asp:GridView BackColor="Azure" GridLines="None" ShowHeader="False" Width="100%" ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="ItemID" DataSourceID="ObjectDataSource1"> <Columns> <asp:TemplateField> <EditItemTemplate> <asp:Panel ID="Panel9a" runat="server" Width="80%"> <table width="100%"> <tr> <td width="30%">Title:<br /><asp:TextBox Font-Bold="true" ID="TextBox1" runat="server" Text='<%# Bind("Title")%>' Width="100"></asp:TextBox></td> <td width="55%">Desc:<br /><asp:TextBox ID="TextBox2" runat="server" Text='<%# Bind("Description")%>' Width="150"></asp:TextBox></td> <td width="15%">Pri:<br /><asp:TextBox ID="TextBox3" runat="server" Text='<%# Bind("Priority")%>' Width="40"></asp:TextBox></td> </tr> </table> </asp:Panel> <ajaxToolkit:HoverMenuExtender ID="hme1" runat="Server" TargetControlID="Panel9a" PopupControlID="PopupMenu" HoverCssClass="popupHover" PopupPosition="Right"> </ajaxToolkit:HoverMenuExtender><!--added closing tag to be consistent with hme2 below--> <asp:Panel ID="PopupMenu" runat="server" Width="80" CssClass="popupMenua"><!--modified styling--> <asp:Panel ID="RoundedCornersPanela" runat="server" Width="80px" CssClass="ahovermenuroundedPanel"><!--added panel--> <div style="text-align: center;"> <asp:LinkButton ID="LinkButton1" runat="server" CausesValidation="True" CommandName="Update" Text="Update"> </asp:LinkButton> <br /> <asp:LinkButton ID="LinkButton2" runat="server" CausesValidation="False" CommandName="Cancel" Text="Cancel"> </asp:LinkButton> </div> </asp:Panel><!--RoundedCornersPanela--> </asp:Panel><!--PopupMenu--> <ajaxToolkit:RoundedCornersExtender ID="RoundedCornersExtender1a" BehaviorID="RoundedCornersBehavior1" runat="server" TargetControlID="RoundedCornersPanela" Radius="6" /><!--added extender--> </EditItemTemplate> <ItemTemplate> <asp:Panel ID="PopupMenuED" runat="server" Width="80" CssClass="popupMenua"><!--modified styling--> <div> <asp:Panel ID="RoundedCornersEDPanel" runat="server" Width="80px" CssClass="ahovermenuroundedPanel"><!--added panel--> <div style="text-align: center;"> <div> <asp:LinkButton ID="LinkButton1" runat="server" CommandName="Edit" Text="Edit"> </asp:LinkButton> </div> <div> <asp:LinkButton ID="LinkButton2" runat="server" CommandName="Delete" Text="Delete"> </asp:LinkButton> </div> </div> </asp:Panel><!--ID="RoundedCornersEDPanel"--> </div> </asp:Panel><!--ID="PopupMenuED"--> <!--RoundedCornersExtender1b placeholder--> <asp:Panel ID="Panel9b" runat="server"> <table width="100%"> <tr> <td width="25%"><asp:Label Font-Bold="true" ID="Label1" runat="server" Text='<%# HttpUtility.HtmlEncode(Convert.ToString(Eval("Title")))%>'></asp:Label></td> <td width="50%"><asp:Label ID="Label2" runat="server" Text='<%# HttpUtility.HtmlEncode(Convert.ToString(Eval("Description")))%>'></asp:Label></td> <td width="25%"><asp:Label ID="Label3" runat="server" Text='<%# Eval("Priority")%>'></asp:Label></td> </tr> </table> </asp:Panel> <ajaxToolkit:HoverMenuExtender ID="hme2" runat="Server" HoverCssClass="popupHover" PopupControlID="PopupMenuED" PopupPosition="Left" TargetControlID="Panel9b" PopDelay="25"> </ajaxToolkit:HoverMenuExtender> </ItemTemplate> </asp:TemplateField> </Columns> </asp:GridView> <asp:ObjectDataSource ID="ObjectDataSource1" runat="server" DeleteMethod="Delete" InsertMethod="Insert" OldValuesParameterFormatString="original_{0}" SelectMethod="Select" TypeName="SessionTodoXmlDataObject" UpdateMethod="Update"> <DeleteParameters> <asp:Parameter Name="Original_ItemID" Type="Int32" /> </DeleteParameters> <UpdateParameters> <asp:Parameter Name="Title" Type="String" /> <asp:Parameter Name="Description" Type="String" /> <asp:Parameter Name="Priority" Type="Int32" /> <asp:Parameter Name="Original_ItemID" Type="Int32" /> </UpdateParameters> <InsertParameters> <asp:Parameter Name="Title" Type="String" /> <asp:Parameter Name="Description" Type="String" /> <asp:Parameter Name="Priority" Type="Int32" /> </InsertParameters> </asp:ObjectDataSource></ContentTemplate></asp:UpdatePanel>

AlwaysVisibleControl ajax beta 2 toolkit:

<asp:UpdatePanel ID="update" runat="server"> <ContentTemplate> <div style="width:230px;height:100px;"> <asp:Panel ID="timer" runat="server" Width="220px" BackColor="White" ForeColor="DarkBlue" BorderWidth="0" BorderStyle="solid" BorderColor="DarkBlue" style="z-index: 1;"> <div style="width: 100%; height: 100%; vertical-align: middle; text-align: center;"><p>Current Time:</p><span id="currentTime" runat="server" style="font-size:xx-large;font-weight:bold;line-height:40px;"/></div> </asp:Panel> <ajaxToolkit:AlwaysVisibleControlExtender ID="avce" runat="server" TargetControlID="timer" VerticalSide="Top" VerticalOffset="10" HorizontalSide="Right" HorizontalOffset="10" ScrollEffectDuration=".1" /> <ajaxToolkit:RoundedCornersExtender ID="RoundedCornersExtender1" BehaviorID="RoundedCornersBehavior1" runat="server" TargetControlID="timer" Radius="14" /> </div>

Quick question for you - your posting example code - but are you getting errors? Fiddler would be able to provide some additional input - so can you provide some additional info. I tried rounded corners with some other controls myself and all I got some explicit errors that I annotated...http://forums.asp.net/thread/1440377.aspx(I never bothered to bug report it as I simply got tired of posting in so many places and never seem to get the issues addressed or they dissapear ...)

What exactly is the description of the problems in the examples...


Thanks - the description of the problem is: Has anyone had any luck in using the RoundedCorners control with any other controls, such as HoverMenu, Popup, etc?

Answer - yes, if you tinker with various toolkit samples, applying the RoundedCorners extender works just fine.


Datagrid in ajax toolkit beta 2 HoverMenu sample

<asp:UpdatePanel ID="up1" runat="server"> <ContentTemplate> <asp:Panel ID="RoundedGrid" runat="server" Width="100%" CssClass="ahovermenuroundedPanel"><!--added panel--> <ajaxToolkit:RoundedCornersExtender ID="RoundedCornersExtender1" BehaviorID="RoundedCornersBehavior1" runat="server" TargetControlID="RoundedGrid" Radius="13"/><!--added extender--> <asp:GridView BackColor="orange" GridLines="None" ShowHeader="False" Width="100%" ID="GridView1" runat="server" AutoGenerateColumns="False" DataKeyNames="ItemID" DataSourceID="ObjectDataSource1">

StyleSheet.css

/* Rounded Corners*/.ahovermenuroundedPanel/*for roundedcorners-hovermenu demo*/{width:80px;background-color:orange;/*for demo clarity*/}


Here's what I tried. And got a quirky behavior. I tried to use RoundedCorners with a TextBox control. Since there is no restriction on what type of control it can extend I thought it would be interesting to see how it behaved if used with a text box.

Well it did not round the corners of the text box but somehow when I put my mouse over the text box I got a crosshair cursor the one you get when you are over a draggable item. If i clicked the textbox it selected the textbox like in the design view in VS. With extension points at the corners and the middle of the sides. I could then put the mouse on one of those points and the cursor would change to a "resize" cursor and I could actually drag the mouse and see an outlined shape being resized though the text box was not being resized. Very peculiar indeed. I wasn't using a Master Page but I had two RoundedCornerExtenders on the page one for a normal Panel control and the other for the TextBox.

The question is can anyone else reproduce the behavior and if they can then I suppose its a bug. Maybe there should be a way to specify in an extender what type of controls it DOESN'T support, so that when you try to assign the TargetControlID to a control that is not supported then a validation message can appear at design time warning the user that the type is not supported. I will work on changing the RoundedCornersExtender control to add that functionality for the types of controls that I know it doesn't work with.

If you have any other .NET server controls you found that it does not work with then let me know.

Thanks


I intepreted the question like Silver did. Which is can you use the RoundedControlExtender with other controls like GridView, Textbox, checkbox. What I mean by that is can you set the TargetControlID of the RoundedCornersExtender to an ID of a control of type Textbox or GridView or Checkbox? The thing is in ALL the examples shown above in this chain the extender is used to extend the Panel. If a Panel is the only thing that can be extended with this extender then why not restrict it to a panel like the Textboxwatermark extender is restricted to controls of type TextBox only or ConfirmButton Extender is restricted to controls of type Button only??

Thanks


I too would very much like the roundercorners to works with the gridview control. Right now I'm trying to put my gridview in a panel with rounded corners but the panel doesn't seem to want to auto-resize with the gridview, so i'm having some issues there.