webusercontrol

External JS file in web user control?

In a html page we use the head tag to add reference to our external .js files .. we can also include script tags in the body .. But how do we include our external .js file in a web user control? After little googling I got this. It works but is this the only way? ScriptManager.RegisterStartupScript(this.Page, Page.GetType(), "MyUniquek...

How do I stop execution going into a UserControls PageLoad Method?

I have a MasterPage, with my Usercontrol inside a div. I can set visible=false to the UserControl and to the containing div, and this works fine. But the Page_Load of the UserControl is always hit. Is this by design, or am I missing how to stop page execution going into the Page_Load method of the UserControl. ...

How to get Visual Studio's designer to render CSS correctly in an ASP.NET Web User Control?

When developing a web user control, I'm styling everything with CSS. Whenever I look at the control in the designer, none of the CSS is rendered, or course, because I'm not looking at it in the context of the page where my link element is declared to my CSS file. Plus, Visual Studio will include a warning: The class or CssClass valu...

Web user control usage

Is there a simple way to determine where web user controls (wuc) are used in a solution? I'm trying to get an overview of what's going on in a rather big applications, where I have a large number of wuc's, used both in aspx and nested in other wuc's. Any suggestions are welcome. :) ...

Passing Control ID from one Web User Control into another

I have a Web User Control that holds many others User Controls. I'd like to name those embedded controls based on the ID of the parent user control. I'm trying this code inside the main User Control: <myLibrary:myChildUserControl1 ID="<%=ID%>" runat="server" /> or <myLibrary:myChildUserControl2 ID="<%=ID%>_OkButton" runat="server" /...

How to hide property of ASP.NET custom control in aspx page ?

Hi, I'm writing ASP.NET custom control, and I want it to have a few properties which should be visible only from code behind during run-time - I mean, these properties should not be visible both in a designer and in a aspx code of page containing this control. I've tried to use following attributes: [DesignerSerializationVisibility(Des...

Temporary file contains reference to constructor with no arguments when it shouldn't

I have some WebUserControls that take a parameter to determine how they initialize themselves. However, when I compile the page I get the error 'ControlName' does not contain a constructor that takes '0' arguments I am not calling it anywhere without an argument, it appears that a reference is being generated in a temporary file. I...

ASP.Net event only being raised every other time?

I have an ASP.Net web user control which represents a single entry in a list. To allow users to reorder the items, each item has buttons to move the item up or down the list. Clicking on one of these raises an event to the parent page, which then shuffles the items in the placeholder control. Code fragments from the list entry: Public ...

VS2008 loading designermode takes forever

Is there anything that can be done about the Designer mode for a ascx file taking forever to show? I'm currently waiting for like 1 minute and still nothing happened. This is not the first time i see this problem, the ascx file doesn't even have any components to show yet... The web user control is like empty and still it won't load. Wha...

Call a function of a Web User Control from the parent page

Hi, I'm creating a comments web user control. I want to use this comments control on distinct pages like: articles, attractions and categories. So, on the articles page I delcare the Web User Control <uc1:Comments ID="Comments1" runat="server" /> On the control, there is a funtion call loadComments public void LoadComents(int ID,...

Calling jquery function from ascx not working

Hi Guys, I'm having a problem with the following situation. I have an ascx which contains a submit button for a search criteria and I am trying to call a validation function in a js file I've used throughout the site (this is the first time I'm using it in an ascx). Now I've just tried this: <script type="text/javascript" src="js/jqu...

User control's elements not getting initialised when added dynamically?

Hi All I've got a custom ASP.Net web user control I've built; done this enough times before but this one is misbehaving and I can't spot why. Where the calling page includes the user control directly in its markup, all is well and the control behaves as expected. However if the page adds this particular control dynamically (to a place...

Writing custom controls...

HI Guys, I'm interested writing a set of custom controls (most likely in ASP.NET), was wondering what sort of guidelines I should follow. - Is there any generic requirements for UI controls that should be followed? - When writing documentation / samples etc, any guidelines on what they should include? I know it's very general question bu...

Problems with UserControl and Inner Properties

I am trying to develop a control that'll allow the developer to populate a collection through markup (e.g. Properties decorated with the attribute PersistenceMode(PersistenceMode.InnerProperty). I have an example from Brian Chavez that more or less does what I want but I want to have the control inherit from UserControl and not Control....

Web User Control with content inside it

Usage : <uc1:WindowControl ID="Window_ExpoNews" runat="server" Height="265px" Title="Expo News" Width="100%"> <ContentTemplate> This content will show in the center cell of this user control. <br /> I can even add real controls. <asp:TextBox ID="TextBox1" runat="server" /> ...

CSS getting distorted while using the custom WebUserControl in an ASPx page

Hi, I have a very simple Web UserControl derived from System.Web.UI.UserControl. At Design Time the user control looks perfect in the VS2008 Pane with all CSS styles. When I drag n drop this control on an aspx page, the CSS style gets applied but some texts get hidden and the CSS looks distorted. I have checked the path of the CSS, Us...

ASP.NET Cache and Output Cache for Controls

Hi there You know I have the way to Cache the data I've got from the SQL Server over data caching. In addition I can output cache web user controls. Whats about a web user control contains data from a SQL database? Does it make sense to cache the data and also cache the control? What is the best solution for the combination of these t...