Showing posts with label cant. Show all posts
Showing posts with label cant. Show all posts

Saturday, March 24, 2012

UpdatePanel and absolute positioning

Hi,

I have been doing alot of searching about how to use absolute positioning with the UpdatePanel. I can't seem to find anything on how htis is done. I have tried a css style sheet, as well as a div tag to no avail. I can get the control to center in the page( with the html center tag ) but i can't seem to be able to set where i like.

Could someone tell me how or put me in the right direction?

Thanks

Just put it inside a regular div, and position that whereever you like.

Hope it helps


Hi,

You know as soon as i posted this, it dawned on me on what to do, but it was to late for me to withdraw it. I had tried a div tag but it wouldn't work, maybe I had it wrong but this is the div tag that i was using...please correct me if I had wrong..

<div id="mypos" style="position:absolute">
<asp:UpdatePanel ....>

etc...

</div>

Not sure if i used it correctly. But i put the updatepanel in a panel and set the style to the panel as absolute.

Did i use the div tag incorrectly?

Thanks


yup that looks correct to me. You probably want to set the left and top style attributes of mypos aswell. good luck.


The UpdatePanel itself renders as a div tag with the same ID as the ClientID of the UpdatePanel. You can use a #UpdatePanel1 type CSS selector to directly position it, without using superfluous containers.

UpdatePanel and custom Extender: two components with the same id cant be added to the appl

I am experiencing some strange behavior in my UpdatePanel which contains a ListView with a DataPager control. The items in the list view each have a custom ModalPopupExtender that is dynamically generated as well as a custom extender control that does some manipulation on an image.

The first page of results loads correctly, and I can move to the next page fine as well. However, when I move back to the first page, Firebug shows me the 'two components with the same id can't be added to the application' exception thrown on each of the items on the first page of the list, on the behavior associated with my custom extender. This to me seems that the partial update does not destroy or dispose the extender's behaviors when I move to the next page, so when I try to render the first page again, those extenders are still sitting in memory.

Now the kicker is, if I go to the next page and back to the first page a second time, my behaviors load correctly. Repeat and they don't show up and new errors are fired. I know this has to do with the lifecycle but I can't seem to pin it down.

Now my custom extender is fairly straightforward and only calls the base dispose() method for its own dispose() function. What am I missing?


I have narrowed down the issue to the fact that the Extender control uses a callback to attach an event to an image that has loaded dynamically from a web service call:

_onMethodComplete : function(result, userContext, methodName)
{
// Wire up image effect
var i = this.get_element();
i.onload = function(i)
{
asyncEffect(i); // This function lives in an external effects.js file
}

// Do after onload event to pick up change
this._setImage(result);
}

Doing this prevents the extender from disposing, possibly because it's still got a handle to an external JS file. I blanked out the image's onload event after the effect completes and the extender works for images that weren't previously on the page, but is still not disposing the extender correctly. Commenting out the wire up code above corrects the issue (obviously without the effects the JS file would bring).

How can I cleanly dispose an extender that references an external JS script?

UpdatePanel and dynamically loaded webusercontrols

Hi,

This is my scenario, I'm can't figure out why the UpdatePanel doesn't update on a child control event.

I have a WebUserControl MyUserControl.ascx that looks like this:

1<asp:UpdatePanel ID="upnlMain" runat="server" ChildrenAsTriggers="True" UpdateMode="Conditional">
2 <ContentTemplate>
3 <asp:Panel ID="pnlContainer" runat="server">
4 </asp:Panel>
5 <asp:Label ID="lblTest" runat="server" Text=""></asp:Label>
6 </ContentTemplate>
7</asp:UpdatePanel>
In code behind I'm dynamically loading a dropdownbox as follows:
 
1protected void Page_Load(object sender, EventArgs e)
2 {
3 DropDownList ddl =new DropDownList();
4 ddl.Items.Add(new ListItem("aaa","aaa"));
5 ddl.Items.Add(new ListItem("bbb","bbb"));
6 ddl.Items.Add(new ListItem("ccc","ccc"));
7 ddl.AutoPostBack =true;
8 ddl.SelectedIndexChanged +=new EventHandler(ddl_SelectedIndexChanged);
9this.pnlContainer.Controls.Add(ddl);
10 }
1112void ddl_SelectedIndexChanged(object sender, EventArgs e)
13 {
14this.lblTest.Text = ((DropDownList)sender).SelectedItem.Text;
15 }
In my Default.aspx web page I have one single palceholder:
1<asp:PlaceHolder ID="phHolder" runat="server"></asp:PlaceHolder>
The idea is to load MyUserControl.ascx web user control dynamically into the placeholder, making sure the UpdatePanel of the user controls gets updated on dropdown list event.
 I'm adding this WebUserControl:
 
1protected void Page_Load(object sender, EventArgs e)
2 {
3 UserControl control = (UserControl)LoadControl("~\\MyUserControl.ascx");
4 controlElement.ID ="MyControl";
5 controlElement.EnableViewState =true;
6this.phHolder.Controls.Add(control);
7 }
  Everything works fine except the the updatepanel's update, for some reason, unknown to me, the drowpdown list does a full postback, ignoring the updatepanel that contains it. I'm not sure if I am doing something wrong or what I'm trying to achieve is not doable.
Any help is greatly appreciated.
Thanks,
 Virgil 
 
 


Hi virgilhretcanu,

In the UserControl you need to add the "ddl_SelectedIndexChanged" event to the updatePanel's Trigger Collection. Try like this:

protectedvoid Page_Load(object sender,EventArgs e)

{

DropDownList ddl =newDropDownList();

ddl.ID ="ddl1";

ddl.Items.Add(newListItem("aaa","aaa"));

ddl.Items.Add(newListItem("bbb","bbb"));

ddl.Items.Add(newListItem("ccc","ccc"));

ddl.AutoPostBack =true;

ddl.SelectedIndexChanged +=newEventHandler(ddl_SelectedIndexChanged);

this.pnlContainer.Controls.Add(ddl);

AsyncPostBackTrigger trigger =newAsyncPostBackTrigger();

trigger.ControlID = ddl.ID;

trigger.EventName ="SelectedIndexChanged";this.upnlMain.Triggers.Add(trigger);

}

void ddl_SelectedIndexChanged(object sender,EventArgs e)

{

this.lblTest.Text = ((DropDownList)sender).SelectedItem.Text;

}

Hope this will help you.

Thanks & Regards,

Rajak Shaik.

// Please Mark as Answer if this post helps you.


It works like a charm. Thank you very much Rajak