I have created a page where I have implemented many tabs by ajax control toolkit.
Now I want to access that tabs from implemented page's code behind.
How can I Do this.
try something like this
<asp:TabContainer ID="TabContainer1" runat="server" ActiveTabIndex="0">
<asp:TabPanel runat="server" HeaderText="TabPanel1" ID="TabPanel1">
<HeaderTemplate />
<ContentTemplate>
//CONTROLS COMES HERE
</ContentTemplate>
</asp:TabPanel>
</asp:TabContainer>
Related
I have to set ajax tab panel as in read only property as so its controls also must be have read only property. How can i do that.
You can place the ajax tab panel inside a panel or div and you can disable that panel...
<asp:Panel ID="PnlContact" runat="server">
<ajaxToolkit:TabContainer ID="TabContainer1" runat="server" >
<ajaxToolkit:TabPanel ID="TabPanel1" runat="server" HeaderText="Contacts">
<ContentTemplate>
<asp:Panel ID="InnerPanel" runat="server">
</asp:Panel>
</ContentTemplate>
</ajaxToolkit:TabPanel>
</ajaxToolkit:TabContainer>
</asp:Panel>
Here you can make the Enabled property of TabPanel1 from code behind..
TabPanel1.Enabled= false;
Are you looking anything like this .
http://codeverge.com/asp.net.ajax_control_toolkit/how-to-enable-or-disable-asp.net/21378
Basically I have this situation
Page >
Update Panel >
User Control >
List View >
User Control (Within item template) >
Update Panel
When I click on a button within the inner most update panel, I want the content of the update panel to update. This isn't happening. However, the click handler is being hit fine asynchronously. The update panel just doesn't want to update.
Code - I've created a simple test web app that replicates the problem, and shared it on my google drive: UpdatePanelInListViewTest.zip, but here's the markup:
Page:
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:UpdatePanel ID="ajaxParent" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<uc1:ListUserControl ID="ListUserControl1" runat="server" />
</ContentTemplate>
</asp:UpdatePanel>
List User Control:
<%# Control Language="C#" AutoEventWireup="true" CodeBehind="ListUserControl.ascx.cs" Inherits="UpdatePanelInListViewTest.ListUserControl" %>
<%# Register src="MiniWidget.ascx" tagname="MiniWidget" tagprefix="uc1" %>
<asp:ListView ID="lstTest" runat="server">
<ItemTemplate>
Item
<uc1:MiniWidget ID="MiniWidget1" runat="server" />
</ItemTemplate>
</asp:ListView>
Mini Widget User Control
<%# Control Language="C#" AutoEventWireup="true" CodeBehind="MiniWidget.ascx.cs" Inherits="UpdatePanelInListViewTest.MiniWidget" %>
<asp:UpdatePanel ID="ajaxWidget" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<asp:LinkButton ID="lnkTest" runat="server" onclick="lnkTest_Click">Test</asp:LinkButton>
<asp:Label ID="lblTest" runat="server" Text=""></asp:Label>
</ContentTemplate>
</asp:UpdatePanel>
I've tried different permutations of this; i.e. having the button outside the panel and adding a trigger etc but I just cannot get it to update.
It appears that because the user control is within an item template of the parent list view it causes the update panel to not update for some reason...
The problem is to do with when you call the databind method within ListUserControl.
Moving lstTest.DataBind(); so that it executes within the Page_Load rather than the Page_PreRender fixes the issue for your simple test web app.
have u tried:
<asp:UpdatePanel ID="ajaxPanel" runat="server" ChildrenAsTriggers="true" UpdateMode="Conditional">
<Triggers>
<asp:AsyncPostBackTrigger ControlID="btnTest" />
</Triggers>
<ContentTemplate>
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
<asp:Button ID="btnTest" runat="server" Text="Test" onclick="btnTest_Click" />
</ContentTemplate>
</asp:UpdatePanel>
I have two tab panels, and in each of these there is a user control.
<asp:Label ID="lblWarning" runat="server"></asp:Label>
<asp:TabContainer ID="tabContainer" runat="server">
<asp:TabPanel ID="tab1" runat="server">
<contenttemplate>
<uc3:YYY ID="userControl1" runat="server" />
</asp:TabPanel>
<asp:TabPanel ID="tab2" runat="server">
<contenttemplate>
<uc1:XXX ID="userControl2" runat="server" />
</contenttemplate>
</asp:TabPanel>
</asp:TabContainer>
Now consider that I have a required field validator in one of my user controls, and there is a label in the main page as you see. When I clicked a button in main page, I want to display required field validator's error message in my main page's label(lblWarning).
Is this possible or not, and if yes, how?
Thank you all...
In the end, I could not solve this problem, and I have written a javascript alert function for displaying the required filed validators message.
I have an update panel that has UpdateMode of Conditional and ChildrenAsTriggers set to false. I only want a few controls to cause an asynchronous postback:
<asp:UpdatePanel ID="updPnlMain" runat="server" UpdateMode="Conditional" ChildrenAsTriggers="false">
<ContentTemplate>
// ...
<asp:Repeater ID="rptListData" runat="server">
<ItemTemplate>
<asp:Button ID="btnAddSomething" runat="server" OnClick="btnAddSomething_Click" />
</ItemTemplate>
</asp:Repeater>
// ...
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="btnAddSomething" EventName="Click" />
</Triggers>
</asp:UpdatePanel>
I am getting the following error when I try and load this page:
A control with ID 'btnAddSomething' could not be found for the trigger in UpdatePanel 'updPnlMain'.
Since my btnAddSomething control is in a repeater and might not be there right away it acts like it is nonexistent. How can I get around this?
Because your control is in the repeater control and it is out of scope to the Trigger collection. By the way you don't need to add trigger because your button control is already in the UpdatePanel, it will update when you click the button.
Edit: There is a solution if you really want to update your updPnlMain updatepanel. You can put in another updatepanel and put your button in that panel. e.g.
<asp:UpdatePanel ID="updButton" runat="server" UpdateMode="Conditional">
<asp:Button ID="btnAddSomething" runat="server" OnClick="btnAddSomething_Click" />
</ContentTemplate>
and then simply call the updPnlMain.Update(); method in btnAddSomething_Click event.
It will actually do what you are looking for :)
My content page
<asp:updatePanel id="Panel1" runat="server" Visible="true">
<ContentTemplate>
<div>
blah blah
</div>
</ContentTemplate>
</asp:updatePanel>
<asp:updatePanel id="Panel2" runat="server" Visible="false">
<ContentTemplate>
<div>
yada yada
</div>
</ContentTemplate>
</asp:updatePanel>
Code file ..The following code is at the end of Submit button click event :-
Panel1.Visible = false;
Panel2.Visible = true;
Now earlier I was using asp:Panel..then it was working fine..like Panel 1 would hide and Panel 2 would show up instead..it was AFTER I changed asp:Panel to asp:updatePanel that things got screwed up...now the Submit button just won't work !!
What's gone wrong suddenly ?? I changed it to updatePanel so the page doesn't refresh..isn't this how we implement this thing ???
<asp:updatePanel id="Panel1" runat="server">
<ContentTemplate>
<div>
<p>
Type ur name
<asp:TextBox ID="name" runat="server">
</asp:TextBox>
</p>
<asp:Button ID="btn" OnClick="btn_Click" runat="server"
Text="Submit" />
</div>
</ContentTemplate>
</asp:updatePanel>
<asp:updatePanel id="Panel2" runat="server" Visible="false">
<ContentTemplate>
<div>
Thank You!
</div>
</ContentTemplate>
</asp:updatePanel>
At http://msdn.microsoft.com/en-us/magazine/cc163413.aspx#S3 , you can read
Multiple UpdatePanels
A page can host several UpdatePanels. By default, when one UpdatePanel on a page updates, the other UpdatePanels on the page also update. Sometimes that’s what you want, but more often than not, you don’t need every UpdatePanel updating in response to other UpdatePanels.
You can be selective about which UpdatePanel instances update (and when) by setting the UpdateMode property of each UpdatePanel control on the page to "Conditional." Then, when one UpdatePanel updates and calls a server-side event handler, call UpdatePanel.Update on the other panels you want to update. This reduces the load on the server by reducing the number of controls that render, and it reduces the volume of data in the response because UpdatePanels that don’t update don’t add anything to the response.
If you set Visible="false" on an UpdatePanel, it won't be rendered to the client at all. Therefore, if you're doing an Ajax postback, the client isn't going to be able to make the invisible UpdatePanel visible, because it just isn't there.
Think of UpdatePanels just as markers, showing which bits of your page you want to update on an Ajax postback. For your scenario, I think the easiest solution would be to use both UpdatePanels and Panels. Also, because the two things you're updating (the two Panels) are right next to each other, there's no need for two separate UpdatePanels:
<asp:updatePanel id="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Panel id="Panel1" Visible="true" runat="server">
blah blah
</asp:Panel>
<asp:Panel id="Panel2" Visible="false" runat="server">
yada yada
</asp:Panel>
</ContentTemplate>
</asp:updatePanel>
Then in the code-behind, change the Visible property on the Panel controls.
I do not know where your Submit button is, but maybe try updating those panels with:
Panel1.Update();
Panel2.Update();