set read only property to the ajax tab panel in asp.net - c#

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

Related

Howto sort several UpdatePanels/Panels in a aspx via c# code?

I'm developing a website where I need to sort some static asp:UpdatePanels and asp:Panels including all controls inside these panels in according to database setup But I don't know how to do it :-( Is there anyone who can help me?
I have tried to setup all the panels including both Panels and UpdatePanels in an aspx file and in code behind reordered them with the following code with no success :-(
this is my aspx:
<asp:Panel runat="server" ID="panelMain">
<asp:UpdatePanel runat="server" ID="2"></asp:UpdatePanel>
<asp:Panel runat="server" ID="1"></asp:Panel>
<asp:UpdatePanel runat="server" ID="3"></asp:UpdatePanel>
</asp:Panel>
this is my c# code:
Control control2 = panelMain.FindControl("2");
Control control1 = panelMain.FindControl("1");
Control control3 = panelMain.FindControl("3");
panelMain.Controls.Clear();
panelMain.Controls.Add(control1);
panelMain.Controls.Add(control2);
panelMain.Controls.Add(control3);
The UpdatePanel must be registered in ScriptManager - and I can't sort the components - so I don't know what to do and how to register them :-(
According to Mike Perrenoud's answer on this Question you can make all variants of the three controls invisible and make only the ones visible which are needed and assign the active panel the values that you want to show like you already do.
The aspx site could look like this:
<asp:Panel runat="server" ID="panelMain">
<asp:UpdatePanel runat="server" ID="UpdatePanel1" Visible="false">
</asp:UpdatePanel>
<asp:Panel runat="server" ID="Panel2" Visible="false">
</asp:Panel>
<asp:UpdatePanel runat="server" ID="UpdatePanel2" Visible="false">
</asp:UpdatePanel>
<asp:UpdatePanel runat="server" ID="UpdatePanel3" Visible="false">
</asp:UpdatePanel>
<asp:UpdatePanel runat="server" ID="UpdatePanel4" Visible="false">
</asp:UpdatePanel>
<asp:Panel runat="server" ID="Panel3" Visible="false">
</asp:Panel>
<asp:Panel runat="server" ID="Panel4" Visible="false">
</asp:Panel>
<asp:UpdatePanel runat="server" ID="UpdatePanel5" Visible="false">
</asp:UpdatePanel>
<asp:UpdatePanel runat="server" ID="UpdatePanel6" Visible="false">
</asp:UpdatePanel>
</asp:Panel>
And on the C# side you can assign values and make it visible:
UpdatePanel updatePanel1Data = (UpdatePanel)panelMain.FindControl("UpdatePanel1");
Panel panel1Data = (Panel)panelMain.FindControl("Panel1");
UpdatePanel updatePanel2Data = (UpdatePanel)panelMain.FindControl("UpdatePanel2");
UpdatePanel3 = updatePanel1Data;
Panel2 = panel1Data;
UpdatePanel4 = updatePanel2Data;
UpdatePanel1.Visible = false;
Panel1.Visible = false;
UpdatePanel2.Visible = false;
UpdatePanel3.Visible = true;
Panel2.Visible = true;
UpdatePanel4.Visible = true;
This way it seems for the user that you reordered the panels.
Example is not testet, but it could give you an idea.

Want to Access Tabs thru page code behind

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>

A control with ID could not be found for the trigger in UpdatePanel

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 :)

Update panel does not make a postback for user control

The update panel does not make a postback when calling Update !
<ajax:TabPanel ID="EmployeesTab" runat="server">
<ContentTemplate>
<asp:UpdatePanel runat="server" ID="MyUpdatePanel" UpdateMode="Conditional">
<ContentTemplate>
<GW:MyUserControl ID="MyUserControlId"
runat="server" />
</ContentTemplate>
</asp:UpdatePanel>
</ContentTemplate>
</ajax:TabPanel>
private void PopulateEmployees()
{
MyUserControlId.EntityId = SelectedEntity.Id;
MyUpdatePanel.Update();
}
Any help!
The UpdatePanel has known problems when inside an AjaxControlToolkit templated control.
This is an old article, but the issue still exists in the current version of the AjaxControlToolkit: http://blogs.sitepoint.com/atlasupdatepanel-template-really-darned-kewl/
The suggested workaround is to wrap the TabPanel in the UpdatePanel rather than vice-versa.

Need help with updatePanel

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();

Categories

Resources