473,387 Members | 1,512 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Custom Server Control not working after uploaded

sanjib65
102 100+
I try to create a custom control that will say, Hello + ComputerUserName.

I have added in my App_Code folder a WelcomeLabel.cs file:

Expand|Select|Wrap|Line Numbers
  1. // WelcomeLabel.cs 
  2. using System; 
  3. using System.ComponentModel; 
  4. using System.Security.Permissions; 
  5. using System.Web; 
  6. using System.Web.UI; 
  7. using System.Web.UI.WebControls; 
  8.  
  9. namespace Samples.AspNet.CS.Controls 
  10.     [ 
  11.     AspNetHostingPermission(SecurityAction.Demand, 
  12.         Level = AspNetHostingPermissionLevel.Minimal), 
  13.     AspNetHostingPermission(SecurityAction.InheritanceDemand, 
  14.         Level = AspNetHostingPermissionLevel.Minimal), 
  15.     DefaultProperty("Text"), 
  16.     ToolboxData("<{0}:WelcomeLabel runat=\"server\"> </{0}:WelcomeLabel>") 
  17.     ] 
  18.     public class WelcomeLabel : WebControl 
  19.     { 
  20.         [ 
  21.         Bindable(true), 
  22.         Category("Appearance"), 
  23.         DefaultValue(""), 
  24.         Description("The welcome message text."), 
  25.         Localizable(true) 
  26.         ] 
  27.         public virtual string Text 
  28.         { 
  29.             get 
  30.             { 
  31.                 string s = (string)ViewState["Text"]; 
  32.                 return (s == null) ? String.Empty : s; 
  33.             } 
  34.             set 
  35.             { 
  36.                 ViewState["Text"] = value; 
  37.             } 
  38.         } 
  39.  
  40.         protected override void RenderContents(HtmlTextWriter writer) 
  41.         { 
  42.             writer.WriteEncodedText(Text); 
  43.             if (Context != null) 
  44.             { 
  45.                 string s = Context.User.Identity.Name; 
  46.                 if (s != null && s != String.Empty) 
  47.                 { 
  48.                     string[] split = s.Split('\\'); 
  49.                     int n = split.Length - 1; 
  50.                     if (split[n] != String.Empty) 
  51.                     { 
  52.                         writer.Write(", "); 
  53.                         writer.Write(split[n]); 
  54.                     } 
  55.                 } 
  56.             } 
  57.             writer.Write("!"); 
  58.         } 
  59.     } 
  60. }
And in my help.aspx Page directive I've added
Expand|Select|Wrap|Line Numbers
  1. <%@ Register TagPrefix="aspSample"  
  2.         Namespace="Samples.AspNet.CS.Controls"%>
While compiling in the local machine, it runs perfectly well and the Hello message comes with Computer User Name. But I've uploaded it to the Internet and opened up the page in my office computer but only Hello comes, the computer user name does not show up.
Dec 24 '09 #1
2 1510
sanjib65
102 100+
Does it by any chance relate to <authenticationmode="Windows"> in web.config file?
Dec 27 '09 #2
Frinavale
9,735 Expert Mod 8TB
Check out this article:

Hosting ASP.NET Applications in Medium Trust


I think it might give you an idea about what's going on.

-Frinny
Jan 4 '10 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: PeterB | last post by:
Hi! I'm using Pure ASP File Upload (http://www.asp101.com/articles/jacob/scriptupload.asp) to upload a file from a client to a server. I am testing both on a local IIS and a remote server. The...
0
by: AndrewF | last post by:
Hi there. I am royally stuck with this so any help would be greatly appreciated. Basically I have a set of classes that create composite controls for the user. One of these is an upload object...
14
by: Rolf Welskes | last post by:
Hello, I have an ObjectDataSource which has as business-object a simple array of strings. No problem. I have an own (custom) control to which I give the DataSourceId and in the custom-control...
4
by: Charles Zhang | last post by:
I created a custom server control whose rendering logic relies on session variables and cookies. It works just fine at run time. The problem is at the design time, because session variables and...
12
by: SAL | last post by:
Hello, Is it possible to read a CSV from the Client, and bind my Datagrid to the data in the CSV file without uploading the file to the Server first? I have tried and in Debug mode on my...
11
by: Nick Gilbert | last post by:
Hi, How can I create a custom control which will wrap its content in a header and footer? eg: Is it possible to create a .NET user control which can surround other controls? eg:...
0
by: ChopStickr | last post by:
I have a custom control that is embedded (using the object tag) in an html document. The control takes a path to a local client ini file. Reads the file. Executes the program specified in...
3
by: Tomasz J | last post by:
Hello Developers, I have a control derived from System.Web.UI.WebControls.WebControl. Control has this property: public string Value { set { _value = value; } get { return _value; }
4
by: =?Utf-8?B?UmljaEI=?= | last post by:
I am trying to create a project using the ASP.NET AJAX accordion control. I would like to dynamically add panes to the control with a form template added when the pane is added. I have tried...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.