Web Forms :: Dynamically Load Usercontrol On TabClick?

Nov 16, 2010

When it comes to the usercontrol specially when they are loaded dynamically on the basis of certain conditions then it becomes a very confusing work. I have read in many forums that the dynamic controls have to be loaded in OnpreInit or OnInit. Some of those links are[URL] But this is useful only when if the we know that we have to load UserControl1, UserControl2 without considering any conditions. But what if I have a Tab control and for each Tab Click I have to load the UserControl dynamically. In that situation how can we add the control in either OnPreInit or OnInit. If I am not mistaken then in such case, then we can add usercontrol in certain events. If we are using a TabControl then we load in Tab_Click , if we are using Menu Control then we use Menu_Click and depending
upon the particular tab or Menu we load associated usercontrols. Hence in these conditions, how can we go with the logic mentioned by above links. I have this confusion for very long time . I am posting little portion of my project here. I am using RadTabControl but it doesnt matter if it is Microsoft TabControl. In the aspx, I have a code to define RadTabControl.

<telerik:RadTabStrip
ID="tabMemberDetails"
runat="server"
Skin="WebBlue"
MultiPageID="tabDetails" SelectedIndex="0"
Align="Justify"
ClickSelectedTab="true"
EnableViewState="false"
ReorderTabsOnSelect="true"
Width="1139px"
OnTabClick="tabMemberDetails_Click" ScrollChildren="true">
</telerik:RadTabStrip>

In the code behind, I am loading usercontrol on the basis of the particular TabClick. tabMeberDetails_Click fires whenever I click on the tabs.ViewState["ControlName"] stores UserControlName on the basis of certain condition and finally i load the usercontrol.

proteced void tabMemberDetails_Click(object sender,
RadTabStripEventArgs e)
{
Conditions......
{
ViewState["ControlName"]=........
}
viewDef=ViewState["ControlName"]
UserControl control = (UserControl)LoadControl("~/Controls/"
+ viewDef + ".ascx");
after this I add control to the RadTabStrip.................. and call bind method.........
}

As you can see from above, I am loading my usercontrol in tabMemberDetails_Click event. I see no other choice to do it in OnPreInit. Can anyone answer if this is the right way to do or there is another way that complies with the logic in the links given above.

View 3 Replies


Similar Messages:

Web Forms :: How To Load Dynamically UserControl That Contains Asp Controls

Jan 19, 2011

I have UserControl that has asp control(<asp:Button runat="server" ID="btn" />) and I want to render it.
I tried 1

[Code]....

It doesn't works because it says that each control that has runat="server" must be in Form.I also tried 2:Because loader.Form is null, I create HtmlForm and added the ctrl to it and then added HtmlForm to loader's Control, BUT it says that it has 2 HtmlForm. So, instead I "injected" HtmlForm to loader like this
[Code]....

Now no error is occurred, BUT StringWriter is empty. don't tell me to add Page to solution and override OnRender. I want to do it as I mentioned above.

View 6 Replies

Web Forms :: Dynamically Load An UserControl With Parameter?

Aug 7, 2010

I have this user control :

[Code]....

and i load it dynamicly in Default.aspx like this :

[Code]....

How can I pass the title value ?

View 4 Replies

Web Forms :: Load UserControl At Runtime And Invoke Methods Present - Dynamically?

Jun 20, 2010

How to load UserControl at runtime and invoke the methods present in that usercontrol dynamically( at runtime)?

View 4 Replies

Web Forms :: Dynamically Load And Display UserControl Using JQuery AJAX And WebMethod

Oct 3, 2012

I want to use same functionality in Ajax:Accordion. Looking for the code for this as well as instead of label in user control i want to bind the grid view.

View 1 Replies

Web Forms :: Dynamically Load UserControl, Access Properties In Parent Page Without Recreating In PostBack

Nov 15, 2010

I have several usercontrols which are loaded based on business logic.However, all of them have webcontrols whose selected/entered value needs to be accessible in parent page on an event.Since there can be any combination of UserControls, I do not want to load all the UserControls in the Parent Page, since they are heavy.

I would like to load only those controls which are supposed to appear on the page, yet access the value from the usercontrol which caused the postback. (I would rather not access using Request.Form) (ViewState is open, but unsuccessful to store value in parent page's viewstate in onClick)Here is a sample scenario

Page: Home

Dynamically Loads: UserControls1

UserControls has TextBox tb and Button btn, causing onClick

When btn is clicked, I want to get value of tb in parent page on PostBack, Page creates UserControl2

View 3 Replies

AJAX :: Load AsyncFileUpload In UserControl Dynamically?

Feb 21, 2011

i put asyncfileupload in usercontrol,and i load this usercontrol dynamically,but uploading process do not works. please help me.how to upload image (usercontrol dynamically) and i show this image after upload.

View 2 Replies

Using Javascript Inside A Dynamically Load UserControl In JQuery Ui Tabs

Jan 25, 2011

I need to insert some JavaScript code inside a UserControl that I load from an Ajax call via jQuery Ui Tabs. Let me explain... This is my View (with jQuery loaded)

<script type="text/javascript">
$(document).ready(function () {
$("#tabs").tabs({
cache: false,
});
getContentTab (1);
});
function getContentTab(index) {
var url='<%= Url.Content("~/Home/getUserControl") %>/' + index;
var targetDiv = "#tabs-" + index;
$.get(url,null, function(result) {
$(targetDiv).html(result);
});
}
</script>
<div id="tabs">
<ul>
<li><a href="#tabs-1" onclick="getContentTab(1);">Nunc tincidunt</a></li>
<li><a href="#tabs-2" onclick="getContentTab(2);">Proin dolor</a></li>
<li><a href="#tabs-3" onclick="getContentTab(3);">Aenean lacinia</a></li>
</ul>
<div id="tabs-1">
</div>
<div id="tabs-2">
</div>
<div id="tabs-3">
</div>
</div>
With these lines of code I call the Ajax function to load the content into a DIV.
This is the Action from the controller:
public ActionResult getUserControl(int num)
{
return PartialView("TestUC", num);
}
And this is the UserControl...
<%@ Control Language="C#" Inherits="System.Web.Mvc.ViewUserControl" %>
Number... <span id="testSpan"><%=Model.ToString() %></span>!!
<input type="button" value="Click me!!" onclick="message();" />
<script type="text/javascript">
function message(item) {
alert($("#testSpan").html());
}
</script>

The problem is that the message() function returns always 1 (instead of returning the correct number). My question is... How should I add the script to my UserControl in order to have my code running correctly?

View 2 Replies

JQuery :: Load Gridview With Paging And Sorting By UserControl Dynamically?

Feb 20, 2011

i want to load a usercontrol that contains a gridview with paging and sorting capabilities without postback.

Code for Load UserControl in case Dynamically is:

[Code]....

View 4 Replies

UpdatePanel Dynamically Loaded Web UserControl Will Disappear After Clicking Any Button Inside The UserControl?

Mar 17, 2011

I've a ASP.Net page (Default.aspx) which will load UserControl (ucontrol.ascx) dynamically into an UpdatePanel. By using UpdatePanel, we believe we're able to prevent the entire page to be posted-back.

My problem is, within the UserControl, we have some form controls, such as inputs and buttons; after the UserControl is loaded, clicking on any button inside the UserControl will cause the UpdatePanel to be blanked. During the investigation, I found that, breakpoints within the Button1_Click() in the code-behind for the UserControl is never reached. Please reference to the code below, this references to [REFERENCE]1.

[code]....

View 2 Replies

Web Forms :: Load Usercontrol In Callback?

Sep 16, 2010

How to load usercontrol in (callback or Page methods or Jquery).

View 3 Replies

Web Forms :: Load An UserControl To A Page?

Oct 27, 2010

i have some usercontrols in "~/Pages/"

my URL will be like ~/Default.aspx?p=Login or ~/Default.aspx?p=ContactUser

now i need to get the QueryString("p") and depend of that i want to load my UserControl To the Default.aspx Page

View 1 Replies

Web Forms :: UserControl Removed When Load Dynamic One

May 20, 2010

in my aspx page i have some controls loadded dynamic and other one loaded static, when i am loading the user control dynamically,the dynamic usercontrols loaded successfully, but all static control inside page will be removed! i load the user control using the bellow code inside PlaceHolder. this is my code in aspx page:

[Code]....

View 4 Replies

Web Forms :: UserControl's Load Event Is Not Fired?

Mar 16, 2011

I have a Page, that has UserControl1.

UserControl1 has UserControl2.

When the page loads UserControl2's Load event is not fired at all.

View 2 Replies

Web Forms :: Usercontrol Doesn't Load Through Dynamic Button

Jan 15, 2011

I have dynamic button in tab panel. I want to load a usercontrol through this button in tab panel. but it does not work!!! would some body please tell me why is that happen? I also debug my code and it works correctlly but user control does not load in tab panel.

[Code]....

View 8 Replies

Web Forms :: Dynamically Loading UserControl From DLL?

Nov 15, 2010

I would like to load UserControl dynamically from DLL in the bin directory.

The dll contains several usercontrols which dynamically create webcontrols within them.

I do not have Virtual Path of the UserControls to use in LoadControl(String virtualpath) and LoadControl(Type, object[]) does not work(why the heck is it there in the first place anyways).

provide me some sample code which takes either the path of dll or assembly name "ServerControls" to load usercontrol "UserControl1" dynamically into placeholder "PlaceHolder1"

View 1 Replies

Web Forms :: Load Into Placeholder By Clicking Button In Currently Loaded Usercontrol

Oct 23, 2010

How can I load a usercontrol into a placeholder on the parent page when a button on the currently loaded usercontrol, in thesame placeholder is clicked: I have a page called default.aspx that has a placeholder called placeholder1 on it into which I want to dynamically load a usercontrol I have 2 usercontrols, user1.ascx and user2.ascx user control user1.ascx has a linkbutton, when the linkbutton is clicked, I want the event to load the usercontrol user2.ascx into thesme placeholder, that is placeholder1

View 1 Replies

Forms Data Controls :: Load The Same UserControl Multiple Times?

Jan 27, 2011

I have a simple UserControl that I've created that simply allows a user to enter the date. For the time being, it has a single Textbox with ID="tbDate". I am trying to dynamically add this control multiple times via (for example) `placeholder.Controls.Add(LoadControl())` but am receiving the error "An entry with the same key already exists". I could, perhaps, change the ID of the elements but then it would be difficult to grab the value entered by the user.

View 3 Replies

Web Forms :: Unable To Add UserControl Dynamically On Postback?

Mar 29, 2010

I am trying to add UserControl dynamically to the page. UserControl is added only once (when the page loads) but on postback it doesn't add again (Only one control is alwasys there).I want to add user control Whenever user clicks "btnAddUCWingControl" so when the page loads for first time, there will be only one control, on postback there must be TWO controls and so on

Here is my .aspx (this is content page)

[Code]....

My .aspx.cs file is
[Code]....

View 2 Replies

Web Forms :: Dynamically Add Controls Inside UserControl

Jan 19, 2010

Im trying to add a new "Question UserControl" dynamically to my page each time the user presses "Add question". This works fine and the last control gets deleted when the "Delete question" is pressed. My problem is that in each of the "Question UserControls" i have a placeholder where i would like to add a new Textbox when the user presses "Add answer" and then delete it once the "Delete answer is pressed". The way it works now when i press add answer, an Answer Textbox gets added to the placeholders in all the added Usercontrols. But i only want to add it to the one UserControl where the user pressed "Add answer".

View 4 Replies

Web Forms :: Passing Value To A Dynamically Added Usercontrol?

May 3, 2010

i want load a usercontrol dynamically and pass a string to it ho do i do it..

View 3 Replies

Web Forms :: Dynamically Upload And Use Usercontrol At Runtime?

Oct 9, 2010

I was wondering if it is possible to upload the .ascx and .ascx.vb of a custom usercontrol into my project directory at runtime via an upload control and then after that use through a database query point my page to load that newly uploaded control via (LoadControl(<newlyUploadedControl>)?

View 7 Replies

Web Forms :: Dynamically Loaded Usercontrol Doesn't Fire PostbackEvent?

Jun 21, 2010

I am trying to dynamically load query form as a user control and build a sql statement based on user selection. I have a dropdownbox for Tablename, FieldName, ConditionalOperators and Value Field. Once the user makes a choice and causes a postback I loose my QueryForm (UserControl) and the selection Changed event never gets fired. I tried reloading the QueryForm on Page Init, still no luck.

View 5 Replies

Web Forms :: Handling Button Clickevent In Usercontrol That Is Being Loaded Dynamically?

Nov 2, 2010

I have ASPX page named ArtifactReporting.aspx where I have 3 linkbuttons. For each button I have 3 different UserControls to be loaded dynamically. So I have written for each click

UserControl uc = (UserControl)this.LoadControl("<ASCX page name>");
divArtifact.Controls.Add(uc);

Now in one of the ASCX page I have a server side button. When I click on the button, the content of the ascx is going off, which is correct, because the page post back is happening and in Page_Load I have not written anything that will load the ASCX page.

how to go about this? I need if I load an usercontrol dynamically, I should be let the users carryout operation that usercontrol.

View 6 Replies

Forms Data Controls :: Dynamically Binding The Usercontrol On Button Click?

May 5, 2010

1. When executed I have a "Add Building" and "Click here to add tower" on the page.

2. When clicked on "Add Building" a editable gridview appears when I enter the text and say update.

3. When I click on "Click here to add tower" another button "Add Tower" is displayed on the

page.

4. On this "Click here to add tower" event I have called the usercontrol, where the usercontrol has a editable gridview and a button called "Add Tower".

5. When I click on "Add Tower" a editable gridview should be displayed but the editable gridview is not displayed ,it disappears.

6. Postback is happening ,so I am not getting where and how to handle the postback and even the viewstate

[code]....

View 2 Replies







Copyrights 2005-15 www.BigResource.com, All rights reserved