Showing posts with label basic. Show all posts
Showing posts with label basic. Show all posts

Monday, March 26, 2012

UpdatePanel + Invisible control = Problems

Hi Guys,

I created my own UserControl that only contains the following. (The code for a basic DropDownExtender) The control is called ProgEdit

1<cc1:DropDownExtender ID="dde" runat="server" TargetControlID="lblAssigned" DropDownControlID="DropPanel"></cc1:DropDownExtender>
2<asp:Label ID="lblAssigned" runat="server" Text="Label" Style="display: block; width: 300px; padding:2px; padding-right: 50px; font-family: Tahoma; font-size: 11px;" ></asp:Label>
3<asp:Panel id="DropPanel" runat="server" Style="display :none; visibility: hidden;background: url(http://localhost/project/images/ajax-menu-bg.gif) repeat-y 0 0 #FAFAFA; z-index: 1000;">
4 <asp:LinkButton runat="server" ID="lnkName" />
5</asp:Panel>

I've got a seperate page that contains an update panel. The update panel contains a ProgEdit control which is inially invisible.

1<asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional">
2<ContentTemplate>
3 <ds:ProgEdit runat="server" id="progEdit" visible="false" />
4 <asp:Button runat=server ID="btntest" OnClick="VisibleEdit"/>
5</ContentTemplate>
6</asp:UpdatePanel>

The problem: When I click the btnTest the ProgEdit control is set to visible. But the DropDownExtender control doesn't work correctly. (The dropdown image on the side is missing)
Whats wrong?

If I remove the UpdatePanel, the DropDownExtender runs fine.
If I add another ProgEdit anywhere on the page (which isnt set to Visible=false) it runs fine.

Any ideas?

Any ideas?

Saturday, March 24, 2012

UpdatePanel + User Controls + javascript

I am have some problems executing some basic javascript from a user control within an update panel.

The UpdatePanel is as follows:

<atlas:UpdatePanel ID="DetailsPanel" Mode="Conditional" runat="server">
<ContentTemplate>
<div id="title_details" runat="server">
<asp:LinkButton ID="what"
OnClick="foo2"
Visible="false"
Font-Size="X-Small"
runat="server">
CLICK ME!
</asp:LinkButton>
</div>
</ContentTemplate>
</atlas:UpdatePanel>
The user control gets addes to the "title_details" div's controls as follows:

protected void foo(object sender, EventArgs e)
{
Control detailControl = (Control)Page.LoadControl("DetailsControl.ascx");
(detailControlas DetailsControl).upc_guid = (senderas LinkButton).CommandName;
title_details.Controls.Add(detailControl);
hideTitleBrowser();
what.Visible =true;
DetailsPanel.Update();
}

and the javascript is add as follows:

protected void Page_Load(object sender, EventArgs e) // in DetailsControl.ascx
{
using (BrowserGateway be =new BrowserGateway())
{
upc = be.getTitleByUpcGuid(1,"EN",upc_guid);
}
String scriptString ="function showTab( tab ){" +"var tabs = [\"tab1\",\"tab2\"];" +"for(i=0; i < tabs.length; i++){" +"var obj = document.getElementById(tabs[i]);" +"obj.style.display = \"none\";" +"}" +"var obj = document.getElementById(tab);" +"obj.style.display = \"block\";" +"}";

Page.ClientScript.RegisterClientScriptBlock(this.GetType(),"showHidetabs", scriptString);
}


Any ideas?Hi,

1) You should use only server controls inside an UpdatePanel, otherwise you may have troubles with the associated Atlas controls.

2) Try to register your script as a startup script instead of an inline script.

Hope it helps.