Showing posts with label hide. Show all posts
Showing posts with label hide. Show all posts

Monday, March 26, 2012

trigger event doesnt fire when target control in show/hide panel

I have the following code with the basic required elements to produce the problem:

1<body>2<form id="form1" runat="server">3<asp:ScriptManager ID="ScriptManager1" runat="server" />4<div>5<asp:UpdatePanel ID="UpdatePanel1" runat="server">6<ContentTemplate>7<ajaxToolkit:PopupControlExtender ID="PopupExtender" runat="server" TargetControlID="lbTest"8Position="Right" PopupControlID="buttonPanel">9</ajaxToolkit:PopupControlExtender>10<asp:ListBox ID="lbTest" runat="server" Width="154px"></asp:ListBox>11</ContentTemplate>12<Triggers>13<asp:AsyncPostBackTrigger ControlID="btnAddItem" EventName="Click" />14</Triggers>15</asp:UpdatePanel>16<br />17<asp:Panel runat="server" ID="buttonPanel">18<asp:Button ID="btnAddItem" runat="server" OnClick="btnAddItem_Click" Text="Button" />19</asp:Panel>20</div>21</form>22</body>

The click event is never fired, though the postback occurs.

Any thoughts? Am I doing something "illegal" with the arrangement here? I have a whole form I want to show only in certain circumstances, the results of which should trigger the event to update the main page. How would I do this with Atlas if the given arrangement doesn't work?

TIA, Jeff.

Jeff,

This problem occurs because the PopupControlBehavior's _onClick method calls e.stopPropagation(). That prevents the WebForms.PageRequestManager._onFormElementClick method from getting called. That prevents the asynch postback information from being created correctly. That prevents the asynch postback from working properly.

I believe Ted added the problematic call a long time ago to improve the UI of the PopupControl. I've just pointed him to this thread for more info...

Wednesday, March 21, 2012

Trying to hide controls on UpdatePanel

I have an UpdatePanel on which there sits a dropdownlist of providers and two labels that show the providers AU and Activity #. When the selectedIndex of the dropdown is zero, I want to hide the labels. I have tried both asp:panel controls with height=0 set in the code behind SelectedIndexChanged event and html div with style.visibility = 'hidden' in a javascript onchange event for the dropdown, and neither does anything. No errors, it just doesn't do anything. Here is my page code.

<asp:UpdatePanel id="UpdatePanel1" runat="server">
<contenttemplate>
<asp:DropDownList id="ddlProviders" runat="server" AutoPostBack="True" OnSelectedIndexChanged="ddlProviders_SelectedIndexChanged"></asp:DropDownList>
<BR />
<DIV style="WIDTH: 100%; HEIGHT: 100%" id="divProviderDetail" noWrap>
<asp:Label id="Label1" runat="server" Text="AU#: " __designer:wfdid="w20"></asp:Label>
<asp:Label id="lblProviderAU" runat="server" __designer:dtid="844424930132022" __designer:wfdid="w17"></asp:Label> <BR />
<asp:Label id="Label2" runat="server" Text="Activity #: " __designer:wfdid="w21"></asp:Label>
<asp:Label id="lblActivityNumber" runat="server" __designer:dtid="844424930132024" __designer:wfdid="w18"></asp:Label>
</DIV>
<BR />
</contenttemplate>
</asp:UpdatePanel>

Any ideas? Thanks.

Protected Sub ddlProviders_SelectedIndexChanged(ByVal senderAs Object,ByVal eAs System.EventArgs)Handles ddlProviders.SelectedIndexChanged
If (ddlProviders.SelectedIndex = 0)Then
lblProviderAU.Visible =False
lblActivityNumber.Visible =False
Else
lblProviderAU.Visible =True
lblActivityNumber.Visible =True
End If
End Sub

Or you could use a panel and set Visible = False for that.


whats the code you using at ddlProviders_SelectedIndexChanged

coz the aspx looks fine here


When I used a panel, I set height=0 so as to not leave a big blank spot. That didn't do anything, height was still the same.


If you don't want anything to move, then just change their text to "" rather than changing their height or visibility.


Setting an element's display CSS property to 'none' is a good way to hide elements on the client side. It has the advantage of not removing them from the DOM or rendered HTML (as is the case with those other methods), so you can still manipulate them on the client side later if need be.


document.getElementById('lblAU').class = 'none';

gave me an error when VS scanned the .js file at start. What is the correct syntax?


document.getElementById('lblAU').style.display = 'none';

or if you have a css class

.hide {display: none;}

document.getElementById('lblAU').className = 'hide';