Web Forms :: Error In Web Form / Using A Custom User Control Which Is Compiled Into A Single Assembly

Apr 23, 2010

I am having a very hard time in consuming a very simple web user control that I have built using a Web Application project in VS 2010. The user control works fine as long as the consuming aspx page is in the same project. But after deploying the project using Web Deployment Project into a single assembly I am not able to use it correctly from another aspx page which is in a stand-alone project. The error I see is a null reference exception. Here are the steps that I am following:

1 Create a web user control named WebUserControl_Label using a web application project. This control works fine when used in an webform in the same project.

This is the ASCX of my user control :

<%@ Control Language="C#" AutoEventWireup="true" CodeBehind="WebUserControl_Label.ascx.cs" Inherits="TestWebAppWithCustomControl.WebUserControl_Label" ClassName="TestWebAppWithCustomControl.Controls" %>
<asp:Label ID="Label1" runat="server" ></asp:Label>

This is the code behind:

namespace TestWebAppWithCustomControl
{
public partial class WebUserControl_Label : System.Web.UI.UserControl
{
private string _labelText;
public string LabelText
{
set
{
Label1.Text = value;
}
get
{
return Label1.Text;
}
}
protected void Page_Load(object sender, EventArgs e)
{
}
}
}

2. Create a single assembly for the user control above using a Web Deployment project. The name of the assemby is TestWebAppWithCustomControl.

3. Create a webform in another web application project to use WebUserControl_Label user control. This project has TestWebAppWithCustomControl.dll added as a referemce.

This is how I am using the custom control above in an aspx page:

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="ConsumeTestWebAppUserControl._Default" %>
<%@ Register Assembly="TestWebAppWithCustomControl" Namespace="TestWebAppWithCustomControl" TagPrefix="GBS" %>
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
<GBS:WebUserControl_Label Id="label1" runat="server" LabelText="This is custom label" />
</div>
</form>
</body>
</html>

The problem is that .NET throws a Null Reference Exception when its trying to set the label text via the LabelText property. It looks like that the label control that lives inside the WebUserControl_Label user control is not getting instantiated and is always null.

I have found a few articles online that talk about creating such distributable user controls using ASP.NET website projects. But if possible I would like to stick with the web application project because of the benefits it brings.

View 1 Replies


Similar Messages:

Custom Server Controls :: Custom Control's Constructor / User To Set That variable In The Properties Window After They Drag The Control Onto A Form?

Mar 4, 2010

I have a custom control which inherit from the Table class and in the constructor, it takes a an integer as an argument. There is no empty constructor.

Is there a way for the user to set that variable in the properties window after they drag the control onto a form.

I know some .NET controls, you can set the source for the parameter to different things like another control's property, QueryString using just the properties window.

Right now, I have to create the control dynamically. I read the query string and then created the object.

View 1 Replies

How To Specify An Assembly File Name For A Compiled Application

May 24, 2010

I have read under: Compiling Web Application Projects [URL]

... this compilation model creates a single assembly, you can specify attributes, such as assembly name and version.

You can supply a PATH (directory name only) in the Visual Studio "Build Options".

But where can the file name for the assembly be specified?

View 1 Replies

Override Resource String In Compiled Assembly?

Feb 24, 2010

Is there any way for me to override the values that are stored in a third party assembly in an embedded resource file?

Using Red Gate's .Net reflector, I can see there are 6 resource items, but I only want to change to of them when using it in my web application.

View 1 Replies

Web Forms :: Custom User Control Embed Another Custom User Control?

Mar 20, 2010

Can a custom user control embed another custom user control?is this "bad practice"?eg if i have a custom user control named "Forums" then 2 more custom controls that are "Read_Forums" and "Write_Forums"and all i need to call is "forums" in the page asking - and then it will put in both functionalities..

View 2 Replies

Security :: System.Data.SqlClient.SqlClientPermission Error - No Custom Assembly - Sys Admin

Aug 12, 2010

I've researched the System.Security.SecurityException: Request for the permission of type 'System.Data.SqlClient.SqlClientPermission, System.Data, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed. error.

So far all the suggestions indicate either a custom assembly that needs a permission change (I don't have any custom assemblies) or requires a setting change on the server (I'm not the admin). This is for a ReportViewer app using RDLC files. So my questions are: Are there any other things to try troubleshooting?

I'm a complete newb at attempting to understand (I don't) what I've read on this subject regarding the server admin part. What do I need to tell the server admin to check out and/or change? I've looked at the commonly referenced post on wss_mediumtrust.config (I have no idea what that is). Post link. But with no clue on what the post is talking about I don't know what to ask the admin for.

View 8 Replies

Custom Server Controls :: Unable To Convert User Control To Custom Control

Oct 27, 2010

I have created a user control and am ready to convert it into a custom control. I am trying to follow:

[URL] the steps mentioned in the link.

I am not seeing Build / Publish Web Site option.

I am using VS 2008. I only see Publish User Control but it doesn't give all the settings mentioned below. When I do publish user control, it just copies the ascx file to the desired location. how can I convert the user control to custom control.

View 2 Replies

Web Forms :: Assign User Control From Another User Control ? Giving Error Object Reference Is Not Set An Instance?

Feb 17, 2011

I am trying to assign user control from another user control ..first time its binding control successfully but when we refresh the data its giving error

saying "Object reference is not set an instance".

how to refresh data from another user control ...

My senerio below :

1 Aspx page

2. User control

calling usercontrol databinding method from aspx page but once it get refreshed ,not allowed to bind it again..

View 2 Replies

Web Forms :: Multiple Layout Varieties For A Single User Control?

Feb 2, 2010

I have a user control that contains an image of a product along with some product details.

If the product image is landscape, I want to render the control one way, and if the product image is portrait, I want to render the control a second way.

Example HTML Layouts (drastically simplified):

<div><table><tr><td>
<p><strong>XXXXXX</strong></p>
</td></tr><table></div>

versus

<div><table><tr><td>
<p><em>XXXXXX</em></p>
</td></tr><table></div>

Right now, both layouts are rendered. How can I conditionally render one layout and not the other?

View 13 Replies

Configuration :: User Leave Form Open For More Than 20 30 Min And Then Click A Button On That Form The Browsers Status Line Shows "Error In Page?

Jul 30, 2010

I have a form that works just fine, problem is that if user leave form open for more than 20 30 min and then click a button on that form the browsers status line shows "Error in page", user then must refresh the page in order for the page function.

View 1 Replies

User/server Control With Custom List Items / Create A Simple Menu User Control

Feb 18, 2011

I'm attempting to create a simple menu user control just as outlined here.

The attached code results in an "Object reference not set to an instance of an object" error, but I can't figure out why.

<%@ Master Language="VB" CodeFile="MySite.master.vb" Inherits="MySite" %>
<%@ Register src="Controls/Menu.ascx" tagname="Menu" tagprefix="my" %>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">......

View 1 Replies

Custom Server Controls :: Registering Controls Of Current Assembly Object Reference Not Set Error

Aug 21, 2010

I have created a simple ASP.net Web Application (2.0) and have added a web user control.

Now in my page I have added this control but I have registered like this,

<%@ Register Assembly="WebApplication1" Namespace="WebApplication1" TagPrefix="Custom" %>

Which means I want to access all the controls in my current Web Application project

Then I have added my user control like this,

<Custom:MyUserControl ID="MyUserControl1" runat="server" PublicProperty="Hello" />

Every thing is fine but when I execute the project, NO control on my user control gets "instantiated" and thus I receive error "Object Reference Not Set"

Note that My Control has,

1) Public property PublicProperty as String

2) 1 Label control

In Load Event Handler I am setting Text property of Label Control to PublicProperty. Here object reference NOT set error occurs (which means Label control is NOT initialized).I don't want to register my control using Src, TagPrefix etc.

View 4 Replies

How To Access A User Control's Parent Form's Controls Inside The User Control's Code Behind

Jun 11, 2010

I have to access the parent form's controls inside an event handler method on my user control's code behind.

View 4 Replies

How To Add A Custom .aspx Into Already Compiled Website

Jan 28, 2011

We have a company product (asp.net website) that gets compiled and distributed to our clients. I need to figure out a way to allow us to add in an ad hoc aspx webpage into the website (so it recognizes the master page, the forms authentication, assemblies, etc) without having to provide them with an un-compiled version of the website product.Is this possible. Is there a better method than having a special compiled version of the website on their server.

View 1 Replies

Custom Server Controls :: Unable To Use A Web User Control Inside Another Web User Control

Mar 10, 2011

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:

[Code]....

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.

What am I doing wrong?

View 2 Replies

AJAX :: Error When Using Control Toolkit - Could Not Load Type From Assembly

Jun 13, 2012

System.TypeLoadException: Could not load type 'System.Web.UI.ScriptReferenceBase' from assembly 'System.Web.Extensions, Version=3.5.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35'.

View 1 Replies

Custom Server Controls :: Use Custom Control/user Control?

Oct 12, 2010

I have 3 pages in each page there is a portion of page where it is common in all these three pages.Thought of making the common stuff as a separate control either User control/Custom control.Any suggestions on which one should i use custom/user control

View 2 Replies

Custom Server Controls :: Custom Tag Not Found For Control / Error: Unknown Server Tag 'custom:AjaxValidator'

Jan 3, 2011

Hope this is the correct forum for this question. I am using VWD 2010 an have a web project and get the following error upon execution:

Parser Error Message: Unknown server tag 'custom:AjaxValidator'.

My code is as follows in the .cs file:

[Code]....
[Code]....

View 1 Replies

Custom Server Controls :: Custom Control Design View Error

Aug 13, 2010

I have created a custom control from scratch and it works fine as in you can build the project that uses it and it works fine at runtime. Problem is when you go to design view the control shows an error in the place of where the control should be rendered.

Error: '<SomeValue>' Could not be set to '<SomeProperty>'

This shows up on all my custom set properties. These properties are created as basic as possible. I can give the properties values in Source view and run the app just fine. I can even add a Onclick event. If I don't set any custom properties the control will render fine in Design view. It's only when I set a value to a custom property.

Property Code Example:

[Code]....

I've even removed the Category and Description tags with no difference.

I don't know if what I said makes sens, but I hope it does.

View 3 Replies

Custom Server Controls :: Custom Control Design Time SiteMap Provider Error?

May 13, 2010

I was referred here by MSDN forums hope this is the right place - I have a custom control (:WebControl) that renders web.sitemap in a specific way. While it runs error free and produces the expected result, at Design-Time it complains

[Code]....

and have tried the SiteMapDataProvider Tag with and without the SiteMapProvider
attribute.Does anybody have (a) any experience with this, or (b) any suggestions as to how to track down the problem?

View 3 Replies

Custom Server Controls :: Custom User Control That Fills Itself?

Feb 15, 2010

I'm new to all of this, so go easy on me. This should be an easy one. I have created a custom SmartContentBlock user control for a CMS.The control works, but only if I invoke the Fill() function in the Page_init event in the codebehind of the ASPX page. My goal is to modify the class file so that the Fill() in the codebehind is no longer neccesary. So, for reference, here's the gist of the current situtation.Controls.cs

[Code]....

ASPX Page

[Code]....

View 3 Replies

Configuration :: Web Form Routing And 404 Custom Error Page?

Jan 28, 2011

I have a problem with my site, and I'm using .net 4, web form routing

I have this route ,routes.MapPageRoute("JobPreview", "jobs/{jobId}/{pg}/{Position}", "~/default.aspx")

so, this page is working fine
http://www.jobsagents.com/jobs/24651/1/automation-qa-engineer

If we remove the last segment of this url, it should be redirected to the custom 404 not found page, but in the deployment server it redirects to the default IIS error page for 404 errors

http://www.jobsagents.com/jobs/24651/1/, on my local machine it's ok, and shows my custom error page.

If we remove the last three segments of the url
http://www.jobsagents.com/jobs it works fine on the deployment server.

View 1 Replies

MVC 2 - Merge All Outputs To A Single Assembly?

Oct 5, 2010

I have a Web Deployment Project in my solution. The solution consists of the MVC2 App and another Class Library.

In the Web Deployment Project properties I have the Merge all outputs to a single assembly option ticked and I have given it a name.

When I look in the bin folder I have all my reference DLL's from my MVC app, a DLL with the name of my MVC project and then a DLL by then name I gave it when choosing the Merge all outputs to a single assembly option.

I imagined this option would create 1 DLL not all DLL's plus another one.

View 1 Replies

.net - Disabling Authentication For A Single Aspx Page (custom Error Page)?

Mar 29, 2010

I am using a custom error page in IIS 6:<customErrors redirectMode="ResponseRedirect" mode="On" defaultRedirect="Error2.aspx"/>I want to disable authentication for the custom error page because the error being raised is related to an authentication module and I don't want to get into an infinite loop and I want to display a clean error page to the user. I have been trying the following configuration to do that.

<location path="Error2.aspx">
<system.web>
<authentication mode="None"/>

[code]...

View 3 Replies

'DataBind' A Single Property Of A User Control?

Dec 3, 2010

Before I get to the question, let me give a bit of background. I'm trying to develop a custom caching mechanism that I can apply to custom built user controls. (Please be aware that I know that there are some built in caching mechanism in .NET) Depending on certain flags set declaratively in the mark-up the control should load a cached version of its previously rendered content or execute normally (and if certain flags are set it should generate a cache of its content for next time it loads). I would like to be able to pass certain flags declaratively in the mark-up and being able to check their value at Page Init and, depending on the flag value, determine whether the control should load a cached version or not.

<uc:MyUC ID="N1" runat="server"
CacheProp='<%# SomeEnum.A | SomeEnum.B |SomeEnum.C %>'
PropA='<%# this.SomePropA %>'
PropB='<%# (this.SomePropB %>'
PropC='<%# this.SomePropC %>'
/>

The problem that I'm facing is that as far as I'm aware I can only get the value of the properties declaratively assigned in the mark-up if I called the DataBind(). However I'm faced with two problems: Firstly calling this.DataBind() from within MyUC will trigger the binding of all its child controls which would defeat the purpose of the cache; also all user controls have been built so that they will not call DataBind() before the LoadComplete event has fired, so to make sure that the parent controls they live in has done its initialisation and has computed the properties that are declaratively passed to the child user control (ie PropA, PropB, PropC).And now the question: is there a way to bind the CacheProp property so to retrieve its value without data binding all other properties and without triggering the data binding of all its child controls?

View 1 Replies







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