Web Forms :: Finding Control Id And Setting Properties In Other Pages?
Oct 23, 2010
im using a webusercontrol (hide.ascx) it has 2 buttons btn_hide,btn_expand
and in my other forms of all like(products.aspx)customers.aspx,orders.aspx
im using a panel conrol(pnl_products) where in im placing all the input controls.
i want to find the panel control in hide.ascx page and to set that
panel.visble=true/false property in this page.
View 2 Replies
Similar Messages:
Jan 25, 2011
I have a user control (i.e. ascx) that comprises of two related list boxes (i.e. once you change the selected item in one list the contents of the other list update). I'm adding this user control dynamically to a page on the click event of a button (i.e. using LoadControl).I wish to set the list box datasource properties, as well as the default selected item of the parent list from my parent page so I created public properties in my user control to accomodate this. I also created an event in my user control that notifes the parent page when the selected item changes in one of the list boxes so I can update the contents of the other list box.
I understand that I have to recreate the user control on every postback in order for it to function correctly but I'm not sure exactly how I should be doing it. I've shown below what I have currently - whilst it works the problem is that on postback I'm always creating the user control with all its default properties and then updating the properties that need to change(?). For example, when the choice in theparent list box changes the datasource of the list box is set twice (once in AddControl and then again in OnParentChanged)? As the contents of the list boxes originate in a database it means I'm making unnecessary calls to the database (unless I do some something like store each unique set of data in the ViewState).
I'd be very grateful if someone could review how I've done things and illustrate how perhaps I should be doing things. I'm not sure if the way I've done this is considered the 'correct' way. For example there may be a better way of doing things would avoid setting the properties twice? I'm a bit unsure of the way I've set the datasource properties of the list boxes and bound them. I wished to set the datasource from the parent page because I might have a second user control on my page that may also use the same datasource and I could reuse it (as opposed to each control making its own call to the database) so I'd like to keep this feature if possible.It would be great if posting code in reply that you use my example as a guide so I know what you're referring to.Here's the code for my user control:
[Code]....
[Code]....
Here's the code for my containing page:
[Code]....
View 1 Replies
Jan 6, 2010
[Code]....
Once the template is loaded and cast back to the TabHeader class, it's null. How can I load that control, set the properties, and use it as the template? Or is the only way to go about doing this to create a custom class?
View 2 Replies
Jan 7, 2010
I am in need of some assistance in regards to how to best set the values of properties for a Web User Control which is being included into a cell of a GridView with dynamically created columns. I have tried a few different approaches, but can't seem to get a satisfactory result. Also, to be completely honest, I am not really sure if I am using best practices for what I am trying to accomplish.
First off a little background:I have a GridView for which we will never know the exact number of columns at run time. The columns are predicated by user selection. I am creating the command text for the DataSet on the fly and then looping through the columns of the resulting DataTable in order to use custom TemplateFields. This works ok for just printing out the row values but not so much for when I need to insert the Web User Control into a cell.The Web User Control is in essence a collection of image links which are used as a "Quick Nav" tool. I need to pass the values of 2 fields from each DataRow to the control via properties (for example, CustID and ProductID). I am using custom TemplateField classes inheriting from ITemplate for displaying my fields and extending the DataBinding event like so: [Code]....
This won't work for my User Control as DataBinding is called after the control is loaded into the page and I need the properties to be set before the Page_Load event of the control is fired.Is there a GridView event I should be looking into instead such as RowCreated or RowDataBound? Or should I modify how I loop through the DataTable by doing rows first, then the resulting columns as I've seen done elsewhere?
View 5 Replies
Feb 25, 2011
I have a simple user control(.ascx) with a asp label inside of it. Using the codebehind(C#) from a aspx page, how can I change the text of that label? I have tried using public classes in my user control and a few other things that I could think of off the top of my head. Can somebody give me a quick example of how this would be done?
View 4 Replies
Apr 20, 2010
I though it would be very simple but I can not get it today.I have a user control, with a grid control contained in it.
public Unit Width
{
get
[code]...
View 1 Replies
Nov 9, 2010
Regarding these two approaches:
<asp:Label ID="Label1" runat="server"><%# DateTime.Now %></asp:Label>
and
Label1.Text = DateTime.Now.ToString();
Which do you use and why?
View 2 Replies
Nov 15, 2011
I am using AJAX Modal Popup extender with Master Pages. Since the ID of the Modal Popup Extender changes due to Master PageĀ I am not able to find it.
View 1 Replies
Apr 23, 2010
How do you find the values of a property (such as whether or not they checked) when the check boxes have been created on the fly?
View 4 Replies
Aug 31, 2010
Page B - loads slowly and needs to do some CPU-intensive operations on the web server.
I noticed that when someone is loading Page B, then Page A also loads slowly. This is even worse if multiple users are loading Page B at the same time. Page A won't finish loading until Page B is done.
Is there a best practice for making sure that Page A can still load quickly? Maybe a config setting or IIS setting that I need to change from its default? With 2 users loading Page B at the same time, the web server CPU usage only gets to 30% so I suspect it might be something I can tweak with the settings.
View 1 Replies
Oct 8, 2010
Is there any easy way to set properties of a Page (or UserControl for that matter) from *within itself*?As an example, I have several .aspx pages which inherit from exactly the same code-behind class, but I need to be able to pass different properties to the class to make them do the correct thing for the specific .aspx.
The only way I've found to do this is to create the following - which works fine, but doesn't feel right....
<script runat="server">
Private Sub Page_Init(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles MyBase.Init
Me.MyProperty = True
End Sub
</script>
It would be a much nicer, simplier and easier solution to be able to be able to set MyProperty = True somewhere... is this possible?The option of hard-coding properties within the class for the "parent" page is not going to work for my situation.
View 2 Replies
Jan 15, 2010
i have a WebControl class called ContentFrame that has a Header property and a Content property.
public WebControl Header {get; set;}
public WebControl Content {get; set;}
Now let's say that I have form x and ContentFrame is on the form. What I want to do is be able to set the the Header and Content properties during design time in the source
<cc1:ContentFrame ID="ContentFrame1" runat="server">
<Header>
<WebControl></WebControl>
</Header>
<Content>
<WebControl></WebControl>
</Content>
</cc1:ContentFrame>
View 5 Replies
Jan 6, 2011
hyperlink in new windows and setting properties
View 1 Replies
Dec 15, 2010
I have some user controls which have properties which need to be set from a form on the page
<uc1:MyPlugin
ID="MyPlugin2"
runat="server"
Property1="Hi"
Property2="0" Property3="<%=Property3%>"
Property4="<%#Property4
%>"
/>
Property3 and Property4 anre both public properties of the page I am on and the user control
Currently the code complaing about Property3 saying it cannot create an object of Int32 from '<%=Property3%>' and Property4 always gets set to 0 (the default)
I do not wish to use the c# code to set these values as this Plugin will be deployed with a CMS which I have no control over
View 3 Replies
Jan 11, 2010
We are trying to use a BasePage class (which inherits from Page) to populate and set the Meta Keywords and Meta Description Tags. I am using masterpages and below is an example code extract... According to examples on the internet, I could then set this also via the Page Directive using the MetaKeywords and MetaDescription properties, but they do not appear.
I have tried setting the CodeFileBaseClass="MyNamespace.UI.BasePage" but this does not work either. Using debug I can see that the BasePage classes' MetaKeywords and MetaDescription properties are not being set within my content page. I can access the properties but not set them.
== BASEPAGE CLASS ==
[Code]....
== PAGE CLASS ==
[Code]....
View 3 Replies
Oct 4, 2010
I have a database which holds the path of an image. It also holds the recomended height and width of the image. My question is how can I set the height and width properties from my database? I have tried the following with no avail:
[Code]....
View 6 Replies
Mar 11, 2011
eI am using themes to set the Gridview font size and font name. I need to set the boundfield to the same font and size as I want it to be application to all the columns in gridview. How can I specify the boundfield properties in the themes.
View 8 Replies
Feb 21, 2011
i have page which is derived from nested master page. Below is the hierarchy
Master.Master
Master2Column.master
Bronze.aspx
The aspx page is derived from master2column and which in turn is derived from master.master.
Now i need to find a control in bronze.aspx page from master.master.cs page. This is where i am getting lost.
My master.master has the contentplaceholder1. Below is my master2column
[Code]....
And the maincontent is in bronze.aspx page. Now i need to find a label called lblTo.
I tried this one
[Code]....
and few other options too. But still i am getting "Object reference not set to an instance of an object".
View 2 Replies
Feb 4, 2010
Some settings in asp.net like viewstate can be controlled at the site (web.config), page, or control levels. What is the order of precedence? What happens, for example, if I set viewstate of site and page levels but on at the control level?
Also, is viewstate for a control the same as control state? Furthermore, what events to use for loading and saving viewstate for controls (is this the same thing as control state?) and also for custom controls?
Similarly, which events should I use to render controls? Is this PreInit and Load? Is this the same for custom controls?
View 1 Replies
Dec 6, 2010
I have the following property:
[Code]....
I want to be able to have the user see the available options when they try to do something such as DateRange = .... (i want intelllisense in here and I can set the values). Is this a possible functionality? I am using VS 2008 .NET 3.5
View 1 Replies
May 27, 2010
I have a gridview that is a directory of people with about 50 pages
How would I make another gridview that had first row with 26 columns, 1 for each letter of the
alphabet and second row with the first page that has last names that start with that letter.
View 6 Replies
Mar 16, 2011
I have a DetailsView which has two fields - one that is visible, one that is not. The first the user fills out, the second I want to auto-populate. Unfortunately, I haven't been able to find a way to set the value in this second invisible field. I've tried adding code like this to the Page_Load:
If Not IsPostBack Then
DetailsView1.DefaultMode = DetailsViewMode.Insert
Dim txt1 As TextBox = DirectCast(DetailsView1.FindControl("Type"), TextBox)
txt1.Text = "administrator"
End If
But this returns an error of "Object reference not set to an instance of an object." how to accomplish this - either using the method above or another method? The hoped for end result is that when a new record is inserted via the DetailsView that this record will include the username (entered by the user) as well as the "type" of "administrator"
View 2 Replies
Nov 7, 2010
In my ASP.NET application I am using a lot of ObjectDataSource controls. I want to set the following three properties globally for all ObjectDataSource controls:
EnableCaching="true"
View 5 Replies
Jun 28, 2010
We have a nested master page which we have made it as a seperate class library.(Becoz many projects use the same master page) Initially we had all our css files,skin files, images inside the Master page project itself. But now we wanted the themes to be global and moved it out to wwwroot as mentioned in the below link.
http://quickstarts.asp.net/QuickStartv20/aspnet/doc/themes/themes.aspx#global
The Masterpage has user controls out of which one user control has the telerik menu. The css is not getting set for that particular user control. We use relative path for setting the style sheet link. But it is not getting set. Its still referring to the old path. But all the skin files, images are pointing to the new global location. Except for the telerik menu rest all is aligned according to the style sheet.
When i do view source, the link to style sheet is pointing to the old location. I dunno why this happening. Is this a telerik issue or i am going wrong somewhere.
View 7 Replies
Nov 15, 2010
i have a setup.aspx page where in i select the theme with buttons so if i click on a button the theme should reflect in all of my pages of project.so how can i write the code do i need to call it in each page.how can i set the initial page to do so.
View 7 Replies