I have the following code on my page:
<asp:ModalPopupExtender ID="mpLabelCheck" PopupControlID="pnlModal" TargetControlID="lstCategory"
OkControlID="btnOK" runat="server" BackgroundCssClass="modalBackground">
</asp:ModalPopupExtender>
<asp:Panel id="pnlModal" CssClass="modalPopup" runat="server">
<p>Please make sure all data is entered before continuing.</p>
<p><asp:Button ID="btnOK" Text="OK" runat="server" /></p>
</asp:Panel>
The target control ID is a dropdownList. What happens is any interaction with the dropdownlist triggers the popup. I'd like to wait until the user makes a selection, then conditionally show the popup based on the result of another method.
Any thoughts on how I can accomplish this?
Use dummy hidden control as target for extender and show it in server code with Show method call
Related
This code is in a user control . and i am providing a sample code structure to get an overview .
<Update Panel UpdateMode= "Conditional">
<panel></panel>
<panel>
<button></button>
</panel>
<updatepanel UpdateMode="Conditional"></updatepanel>
</Updatepanel>
so when i click a button in the second panel , i am supposed to hide that panel and it is happening but simultaneously the other panels are getting refreshed . what could be the possible reason for that ?
Based on the code snippet you may have a couple issues to fix:
Make sure you have a ScriptManager on the page with EnablePartialRendering="true"
Correct your markup by making the <UpdatePanel> elements ASP.NET UpdatePanel controls by prefixing them with "asp:".
Add UpdateMode="Conditional" to both of your UpdatePanel controls
Move the sections you want to update asynchronously into the UpdatePanel controls.
Example
<asp:ScriptManager ID="MyScriptManager" EnablePartialRendering="true" runat="server"></asp:ScriptManager>
<asp:UpdatePanel ID="MyUpdatePanel" runat="server">
<ContentTemplate>
<asp:Label ID="Label1" runat="server" Text="This is a label!"></asp:Label>
<asp:Button ID="Button1" runat="server" Text="Click Me" />
</ContentTemplate>
</asp:UpdatePanel>
The following article is a great resource to learn more about the UpdatePanel with details on it's capabilities.
Understanding Partial Page Updates with ASP.NET AJAX
I have used ajax tab container in my application In that container 4 tabs available.
I need to restrict the users to select the tabs. How can i perform this operation in asp.net application.
I have tried enable=false then user unable to enter the text in the tab body.
can any one help me.
Html:
<ajax:TabContainer ID="tabcontainer" CssClass="Tab" runat="server" ActiveTabIndex="0" EnablePartialRendering="true">
<ajax:TabPanel runat="server" HeaderText="Basic Details" ID="tabpanelBasicDetails" >
<HeaderTemplate>
<asp:Image ID="imgBasicDetailsBlack" runat="server" ImageUrl="~/Images/basicdetails-b.PNG" />
</HeaderTemplate>
<ContentTemplate>
<asp:Button Id="btn1" runat="server"></asp:Button>
</ContentTemplate>
</ajax:TabPanel>
</ajax:TabContainer>
You can review the available Tab API in this article: http://www.asp.net/ajaxlibrary/tabs-control.ashx
There is a OnClientClick event which expects a name of a javascript function to attach to the client-side click event of the tab. You can implement your own logic that checks for the tab press and cancel the event by setting "return false" to disable the operation.
Rumen
I notice the calendar control in ASP.NET does not have an AutoPostBack property. I want that when I select a date from the control, the control must not post back the page. How do I do that?and one thing more when i hover over on the calender it shows me a script. "javascript:__doPostBack('Calendar2','5098')". So my question is how to disable this javascript to don't postback the values
There is no way to turn off the postbacks to the server but you can use updatepanel control which can help you some what.
According to PLBlum at the ASP.NET forums:
The Calendar control included with ASP.NET uses postbacks only. If you
added Microsoft ASP.NET AJAX to the page and put the calendar into an
UpdatePanel, it can reduce the appearance of postbacks by using
callbacks. But it still makes a trip to the server for each click on a
date or month.
Many people have created replacements to the Calendar control that
uses javascript to do the work. I am the author of one, in "Peter's
Date Package". You can locate others in these sites: the Control
Gallery (here under Resources), www.123aspx.com, and www.411asp.net.
You can add like following
<asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Calendar ID="ad_Cal" runat="server" OnSelectionChanged="ad_Cal_SelectionChanged" ></asp:Calendar>
<asp:Button ID="btn_Del_Day" runat ="server" Text ="Remove Day" OnClick="btn_Del_Day_Click" UseSubmitBehavior="False" BackColor="#4AA3DF" Font-Bold="True" ForeColor="White" />
<asp:Button ID="btn_sort_Date" runat="server" Text="Sort Days" UseSubmitBehavior="False" BackColor="#4AA3DF" Font-Bold="True" ForeColor="White" OnClick="btn_sort_Date_Click" />
<asp:ListBox ID="lst_ad_dates" runat="server"></asp:ListBox>
</ContentTemplate>
</asp:UpdatePanel>
notice that you should use UseSubmitBehavior="False" with buttons also to stop postback for buttons in the same updatePanel
It works fine
I think you can use "CalendarExtender" from AjaxToolkit
<asp:TextBox ID="txtCalendarExtender" runat="server"></asp:TextBox>
<cc3:CalendarExtender ID="Calendar1" PopupButtonID="imgPopup" runat="server" TargetControlID="txtCalendarExtender" Format="dd/MM/yyyy">
</cc3:CalendarExtender>
Remember to add this code at the top of your page:
<%# Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc3" %>
Working on an asp.net page I created a custom ajax web user control that displays the contents of a list value (which is loaded via database calls). The control includes "next" and "previous" buttons, as well as a couple text boxes. My initial version used a session variable (iterator) to keep track of where the user is while clicking the buttons and filling the text boxes with values from the List[].
In my next iteration, I need to be able to use this custom control, which will be presented many times in a table (or more probably grid), but I'm having trouble figuring out how to handle the iterator, since the session variable will obviously no longer work.
Does anyone have a suggested approach, or a recommended article?
I solved the problem by creating a second form on my user control that is segregated from the controls contained within the UpdatePanel. Before those controls are refreshed, the segregated control (a label in this case) is programmatically assigned a value and when the control Page_Load event fires it references the segregated label value to keep track of it's current position. I also had to move the ScriptManager out of my control and place it on the page(s) the control will be used on, since there will be several of these custom user controls on the page and only one ScriptManager is permitted per page.
<form id="NaviControl" >
<asp:UpdatePanel runat="server">
<ContentTemplate>
<asp:Panel ID="controlsPanel" runat="server" HorizontalAlign="Center" >
<asp:Panel ID="Panel1" runat="server" >
<asp:Button ID="btnLast" runat="server" Text="Previous" Height="25px" Width="75px" OnClick="btnLast_Click" />
<asp:TextBox ID="tbStatusCode" runat="server" ></asp:TextBox>
</asp:Panel>
<asp:Panel ID="Panel2" runat="server" HorizontalAlign="Center" >
<asp:TextBox ID="tbDescription" runat="server" ></asp:TextBox>
<asp:Button ID="btnNext" runat="server" Text="Next" Height="25px" Width="75px" OnClick="btnNext_Click" />
</asp:Panel>
</asp:Panel>
</ContentTemplate>
</asp:UpdatePanel>
</form>
<form>
<asp:Label ID="lblCounter" runat="server" visible="false" />
</form>
Hope some other nubs find this approach useful.
I am trying to use a FileUpload control in a ModalPopupExtender in an UpdatePanel.
I have set a trigger for my Upload button, so that it does a full postback.
What happens is that after the full postback, all the ModalPopupExtenders that I have in the page show up one after the other at the bottom of my page, rah
I've tried using the AsyncFileUpload control, but have not been able to get the UploadEvent to fire, have tried everything I could find in Google. Decided to stick with the FileUpload control.
<ajaxToolkit:ModalPopupExtender ID="MPEBannerImage" runat="server" TargetControlID="btnBannerImage" PopupControlID="pnlBannerImage" Y="200">
</ajaxToolkit:ModalPopupExtender>
<asp:Panel ID="pnlBannerImage" runat="server" Width="530px" >
<asp:FileUpload ID="FileUpload1" runat="server" />
<asp:ImageButton ImageUrl="btn-UploadFile.png"
ID="btnUpload" runat="server" OnClick="btnUpload_Click" />
</asp:Panel>