Showing posts with label window. Show all posts
Showing posts with label window. Show all posts

Wednesday, March 28, 2012

Dynamic created ModalPopup Window

Hi,

I am having a lot of modal popup windows on my page (20+).

When i click various buttons on my page, various modal popupwindows should apear. But I don't want to define all the windows in the aspx, because the windows are pretty large.

So I think it would be fine to place one Panel containing an UpdatePanel and one ModalPopupExtender on the page and on clicking a button on the page i create an composite control and place it inside the Updatepanel, update() and show the modal dialog from code behind. This works fine if the content of the modal popup doesn't contain any buttons. But when i use buttons inside the popup window, their events doesn't fire at all.

Here is some code:

The ASPX:

 <asp:panel id="pnlPopUp" runat="server" style="display: none">
<div style="background-color: LightGrey">
<asp:panel id="header" runat="server">
<asp:label id="lblHeader" runat="server" />
<asp:linkbutton id="lbClose" runat="server" text="X" onclientclick="$find('mpePopUp').hide(); return false;" />
</asp:panel>
<asp:updatepanel runat="server" id="updPopup" childrenastriggers="true" updatemode="conditional">
<contenttemplate>
<asp:panel id="pnlBody" runat="server" cssclass="body" />
</contenttemplate>
</asp:updatepanel>
</div>
</asp:panel>
<cc1:modalpopupextender id="mpePopUp" behaviorid="mpePopUp" popupcontrolid="pnlPopUp" runat="server" dropshadow="true"repositionmode="RepositionOnWindowResizeAndScroll" targetcontrolid="dummy" backgroundcssclass="modalBackground" />

CODE:

public partialclass _Default : System.Web.UI.Page
{
public MDMWindow2 w2 =null;

protected override void OnInit( EventArgs e )
{
base.OnInit( e );
w2 =new MDMWindow2( );
w2.Bubble +=new EventHandler( w2_Bubble );
}

void w2_Bubble(object sender, EventArgs e)
{
int x = 0;// This Point get NEVER hit}protected void ShowWindow2(object sender, EventArgs e )
{
w2.HeaderText ="WWW2";
updPopup.ContentTemplateContainer.Controls.Add( w2 );
updPopup.Update( );
mpePopUp.Show( );
}

and the code of the control:

using System;
using System.Web.UI;
using System.Web.UI.WebControls;

/// <summary>
/// Summary description for PopUpPanel
/// </summary>public class MDMWindow2 : CompositeControl
{
private Label headerLabel;
private Button button;

public String HeaderText
{
get{EnsureChildControls( );return headerLabel.Text;
}
set{EnsureChildControls( );headerLabel.Text =value;
}
}

public MDMWindow2( )
{
}

public event EventHandler Bubble;

protected override void OnLoad( EventArgs e )
{
base.OnLoad( e );
EnsureChildControls( );
}

protected override void CreateChildControls( )
{
EnsureChildControls( );
headerLabel =new Label( );
headerLabel.ForeColor = System.Drawing.Color.Red;
this.Controls.Add( headerLabel );

button =new Button( );
button.CommandName ="Click";
button.Text ="ClickMe";
Controls.Add( button );
button.Click +=new EventHandler( b_Click );

}

void b_Click(object sender, EventArgs e )
{
Bubble(this, e );// This Point get NEVER hit
}
}

Can anybody help? What is wrong with wiring the eventHandlers? Is the updatepanel the probl?em? Or can anybody show me an better way to create modal popups at serverside?

Thnx

I did something like this using user controls (.ascx files). The .aspx file has an UpdatePanel whose content is an asp:Panel with an asp:PlaceHolder in it and an asp:Button. The button is configured with an OnCommand handler and an initial CommandName of 'Inactive'. A LinkButton on the page triggers a partial postback which does 3 main things: a) does a LoadControl of a .ascx file into the Placeholder; b) changes the CommandName of the Button to "EntryForm" (or something logically associated with the .ascx); c) calls Show() on the modal popup.

After the partial rendering completes, the modal popup is shown. When the Button is pressed, the OnCommand is run, and it uses the CommandName to do the right thing for the particular .ascx that was loaded. It's important that in Page_Load, if it's a postback, that the loaded .ascx is re-loaded (using LoadControl) so that the viewstate is restored and the controls on the .ascx can get updated with the values entered on the modalpopup form. During OnCommand, if a different .ascx needs to be shown, it unloads the Placeholder's controls and uses LoadControl for the next .ascx. If the sequence is done, it sets the CommandName back to "Inactive" and hides the modalpopup.

Hope that helps,

Donnie

This sounds good. But in my Dialogs I will have more various controls like dropdownllist or textboxes wich will have to be bound to an eventhandler too. They have to be in the controls.

It would be perfect, if I can handle the events, which are triggered by my control, inside the page.



Sounds like, then, after you use LoadControl, the page just needs to add event handlers in its code-behind to the controls in the .ascx that was dynamically loaded.

Dynamic Animation

Hi threr;

I want create an show a dynamic animation(exactly like select tag window in this page) using AJAX Control Toolkit animation control. At frist, I dont know how can I create a dynamic animation. Second, I want to call the animation via an event instead of button click.

Hi nima_montazeri,

Check outthis post on how to dynamically create Animations. You can't cause an animation to be played in an event other than those it supports. There is a workaround you could try though. You can create a dynamic OnLoad animation in your event which will play as soon as your page is reloaded - you just have to be careful to clear it out before the next postback.

Thanks,
Ted

Monday, March 26, 2012

DropShadowExtender and target panel separate when window is resized

So here's what's up.

I've got a horizontally scrolling asp panel.

In the panel is a datalist which repeats horizontally.

I have a web user control set as the item template. The user control makes use of the DropShadowExtender.

It works beautifully, until the window is resized, then the shadows and user controls part their ways.

Any ideas?

hello?

Saturday, March 24, 2012

DropShadow Extender

Hi everybody,

I have noticed a problem with this control: when it runs on a page, if the user resize the window browser the control moves to fit to the new size, but the shadow doesn't. It happen this to you too ?

Consider setting TrackPosition="true" for the DropShadowExtender.
Thanks Davis, now it works fine.
Thanks David, now it works fine.

DropDownList in an AJAX modal popup window

We've developed a multicolumn dropdown listbox that works great on a standard Web form, but it's been giving me a lot of grief trying to get it to work in an AJAX modal popup window. For some reason, either the dropdownlist or the popup window's height ends up getting set to -2px, which causes the program to come to a screeching halt.

I don't have any such problem if I use a standard dropdown listbox, but I need to show both a code and a description in the dropdown and a standard dropdown comes with its own set of problems in that circumstance. To separate the description from the code and to evenly align the description, I modified the DataText property by setting it equal to the code plus a tab character plus the description thusly, ddList.DataText = "Code" + Chrw$(9) + "Description". Once it's rendered on the screen, I view the source and it shows all the codes and descriptions with the tab between them allowing the descriptions to be aligned properly. But the browser strips out the tab character and replaces it with a space.

I'm about to give up on this and was wondering if anyone has had any luck doing the same thing?

Allen A.

There is no tab in html. It will be replaced by (or non breaking space). You can add a definite number of non breaking space to format your listitems. Sorry not able to give simple solution.

Wednesday, March 21, 2012

DropDownList control doesnt have CascadingDropDown properties

I'm attempting to follow the cascadingdropdown with database walk through. For some reason in the properties window of the dropdownlist control there isn't a CascadingDropDown property with plus sign all the properties needed to be set to get the example to work, (Category, ParentControID, PrompText, ServiceMethod, ServicePath.)

Does anyone know how to activate these property settings?

Hi,

did you add the CascadingDropDown extender before looking at the properties panel? At what point of the walkthrough are you experiencing this?

Thanks.


One of the first steps in the example is to add the three dropdownlists you'll need. This included in my case using the properties panel to rename each dropdownlist as I added them. Are you not supposed to view any properties of any control prior to adding the cascadingdropdown extender? If this is the case, shouldn't it be in the example?


Hi,

I have the same problem even worse!

When I try to add these property manually, I get an error"Attribute ParentControlID is not a valid attribute".

Thanks


Hi,

The design experience with the Toolkit has changed a fair amount since that walkthrough was written and we haven't had enough time to update it. The CascadingDropDown properties now appear in the Extenders section (it shows up between Data and Layout when sorting by Category) of the property grid. Expand that first and then you should be able to expand CascadingDropDown.

Thanks,
Ted