I have a ASP.Net project that is setup in such a way that it can be dropped into any site and "just work." All the paths are relative to the current file, not relative to the "~". The paths are determined by ThePath = this.TemplateSourceDirectory;
This is working for everything expect registering a custom control that is created and added to one of the pages. I can add the control just fine with the Page.LoadControl but I cant cast it as the correct type to access anything.
How can I add a reference to the class from within the code itself?
I want to use a couple of instances of the same control on a page. The user control is intended to display a list of records in a repeater. The aim is that the second control will show a list excluding the IDs in the first control The control has a number of public properties, including IDsInThisList, and IDstoExclude. The query will exclude the IDs in the second property.
What I would like to do is get the record IDs from the first instance of the control (IDsInThisList), and pass them to the second contro as the IDsToExclude.
I have a test page where I am setting the properties of the controls in code. As you might guess, it's not working! The first control displays the top 3 items, as desired, but the second display the records 1-7, rather than records 4-10 because it is not receiving the IDstoExclude from the first control When I response write the IDstoExclude from the first control in my testpage, the string is empty. (if I do it from within the control, it shows the IDs)
How can I get the controls to fire in order and pass values to each other?
Screen grab of test page + uc and test page code attached
I don't think I understand fully how ASP.NET does inheritance of controls.I have a user control, ucBase, which has an asp.net label in the ascx file. Code behind references the label and it works fine during run time if the control is not a parent for another user parent.
If I have another user control, ucChild, inheriting from ucBase, the label in ucBase's code is always null. ucChild has no controls in its ascx fileThe server controls (like the label) needs to be declared in the ascx file and not created programmatically.What needs to be done for ucBase to see its own controls when it's a parent user control?
How can I access a webform control from a Web User Control?
I have a web form with some textboxes and dropdownlists. I created a Web User Control with other controls (other textboxes) inside it. Now I need to call from the web control source code the values that the controls in my web page have. How do I do it?
I've got a web site that has a master page and that master page (mpMaster that has a user control ucControl1) which has a sub user control (ucControl2), this user control has a property which accepts a value. Now, I have a page that uses the master page and on this page I have another user control (ucPageControl), I need to find a way of setting the value in ucControl2 from ucPageControl. Is this possible at all?
I have a web user control that represents a simple message box. It is used to display simple messages like "Item has been deleted", or "The item was saved successfully".
On the other hand, I have another web user control that represents the item in the form of an editable form (I made this a user control because this is used in two different pages). I want to embed an instance of the message box user control inside the editable form. I am writing this right after the @Control directive:
Instead of using @Register directives, I register the user controls in web.config and so far this has worked just fine.
With the above markup, the project compiles, but whenever I try to navigate to a page that contains this construct, I get an HttpParseException exception. Furthermore, Visual Studio states that the tack w7rc9:MessageBox doesn't represent a known control.
I have an asp.net 3.5 WebSite application where I have a bunch of UserControls.
In some scenarios I have a reference of type Control (System.Web.UI.Control) that I need to cast to a specific User Control type (to access public properties and methods of the User Control).
The User Control classes are all declared in "the global scope", i.e. not within a namespace. However, for some reason, only some of my User Controls is possible to type in a code file and show up in intellisense and some just wont. In one scenario I could write the cast in code anyway and the site would build (but the UserControl type name did not shift in to the ordinary class name color (light green, you know) in VS text editor), but when running the page I still get the error message about missing using directive or a reference...
If I use the VS 2010 "Navigate to" feature (Ctrl+,) and search for a type I usually get one hit for the Type/Class name and another for the actual file. When searching on my User Control class names I only get the file hits, no class representation. This even goes for those User Control types I actually can access in code.
I've tried to compare the User Control classes that work and doesn't work, but I can't find any difference, they are all declared as public partial.