|
code
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Problem with Custom Web Controls in Visual Studio 2005Textbox control. When I add this control to my web page in Visual Studio 2005, I get the following errors in my Error List: Error 1 Request for the permission of type 'System.Web.AspNetHostingPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed. \\myserver\WebRoot\mypage.aspx 81 Error 29 Element 'MyTextBox' is not a known element. This can occur if there is a compilation error in the Web site. \\myserver\WebRoot\mypage.aspx 81 20 \\myserver\WebRoot\ The web control is in a separate vb.Net project from the website. Both are in the same solution. The webcontrol is referenced as a project reference from the website. Whenever I try to reference this control from the Server side code, I get the error: "txtMyTextBox is not declared." in the IDE However, the site runs ok, when I actually visit the website. Also, when I switch to Design Mode, it appears to render the control ok. What could be causing this? How do I get the IDE to know about my control and stop yelling at me about it? The ASP.Net html looks like this: <%@ Page Language="VB" MasterPageFile="~/myMaster.master" AutoEventWireup="false" CodeFile="mypage.aspx.vb" Inherits="mypage" %> <%@ MasterType VirtualPath="~/myMaster.master" %> <%@ Register Assembly="MyControls" Namespace="MyControls" TagPrefix="MyC"%> <asp:Content ID="Content1" ContentPlaceHolderID="ContentMain" runat="Server"> <MyC:MyTextBox ID="txtMyTextBox" runat="server" TextMode="Password" MaxLength="50"></MyC:MyTextBox> </asp:Content> Can you post the control code?
<swesor***@gmail.com> schreef in bericht Show quoteHide quote news:1133291062.689242.316750@g44g2000cwa.googlegroups.com... > So, I have a custom web control that inherits from the standard asp.net > Textbox control. > When I add this control to my web page in Visual Studio 2005, I get the > following errors in my Error List: > > Error 1 Request for the permission of type > 'System.Web.AspNetHostingPermission, System, Version=2.0.0.0, > Culture=neutral, PublicKeyToken=b77a5c561934e089' > failed. \\myserver\WebRoot\mypage.aspx 81 > > Error 29 Element 'MyTextBox' is not a known element. This can occur if > there is a compilation error in the Web > site. \\myserver\WebRoot\mypage.aspx 81 20 \\myserver\WebRoot\ > > The web control is in a separate vb.Net project from the website. Both > are in the same solution. The webcontrol is referenced as a project > reference from the website. > > Whenever I try to reference this control from the Server side code, I > get the error: "txtMyTextBox is not declared." in the IDE > > However, the site runs ok, when I actually visit the website. Also, > when I switch to Design Mode, it appears to render the control ok. > What could be causing this? How do I get the IDE to know about my > control and stop yelling at me about it? > > The ASP.Net html looks like this: > <%@ Page Language="VB" MasterPageFile="~/myMaster.master" > AutoEventWireup="false" CodeFile="mypage.aspx.vb" Inherits="mypage" %> > <%@ MasterType VirtualPath="~/myMaster.master" %> > <%@ Register Assembly="MyControls" Namespace="MyControls" > TagPrefix="MyC"%> > <asp:Content ID="Content1" ContentPlaceHolderID="ContentMain" > runat="Server"> > <MyC:MyTextBox ID="txtMyTextBox" runat="server" TextMode="Password" > MaxLength="50"></MyC:MyTextBox> > </asp:Content> > The code for the custom control can be as simple as just:
Public Class MyTextBox Inherits System.Web.UI.WebControls.TextBox End Class And I still get the error. The weird thing is, these errors only occur in the IDE. The website itself runs fine. Also, the error only occurs when the website is located on a fileshare on a different server from my development box. If my website is located in c:\inetpub\wwwroot, everything is fine. When the website is in the \\myserver\WebRoot\ folder is when I get the error. This leads me to believe the problem is with the System.Web.AspNetHostingPermission permission error. Is there any way I can tell my computer to trust the \\myserver\WebRoot\ folder, the same way it trusts the c:\inetpub\wwwroot folder? (Or at least tell it to trust that folder enough to let my custom control run) I've dug into the configuration files in my C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\CONFIG folder, but I am having a hard time figuring out which files and settings I need to change. After further research, granting FullTrust to the UNC Path of the
webroot folder seems to have solved my problem. The instructions at this URL helped: http://support.microsoft.com/?id=320268
Validators in composite control firing prematurely
VS2005 C# is very BUGGY, please hlp datagrid pixel height not respected ReadOnly (HTML) controls to stay black and not grey How to cycle through checkboxes in a datagrid and find out which ones are checked? repost: custom control client values gone with postback -- no solution found... Help on rendering a control from page ??? Maintaining "id" attribute value in server controls What is the Equivalent of the CurrentRowIndex Property for a DataGrid Web Control? Dynamic user control Event Handling (VS.NET Ent 2003) |
|||||||||||||||||||||||