.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
Sign In
Win Surprise Gifts!!!

Top 5 Contributors of the Month
Gaurav Pal
Post New Web Links

Server.HtmlEncode to all controls

Posted By:      Posted Date: September 27, 2010    Points: 0   Category :ASP.Net


I have used Server.HtmlEncode(MY TEXT) to display data,

I have setted the  page property validateRequest="false" in .config file,

all this is working fine.

since I have large application using hundreds of labels and text boxes to show data,

so, now it is almost impossible ( time consuming ) for me to place Server.HtmlEncode(MY TEXT) every where while setting data to them e.g. in label.text, textbox.text, etc

is there is any way to set the property some where and all the labels and text boxes automatically use Server.HtmlEncode() when i set there textSmile

View Complete Post

More Related Resource Links

Data Points: Report Controls in SQL Server 2005 Reporting Services


Reporting has always been one of the dark arts of development. The tools typically seem to do just enough to get you to a certain point, then leave you to find workarounds to solve more complex issues.

John Papa

MSDN Magazine July 2006

Asp.net server controls in BlackBerry Browser

The article Asp.net server controls in BlackBerry Browser was added by roopeshreddy on Monday, May 24, 2010.

Hi All,Some of the asp.net server controls(.NET 2.0) like DropDownList control, LinkButton etc., has postback property. When User clicks or selects these controls, a Postback will occur. Let us consider LinkButton control, which is extension of the HyperLink

All my server-controls became unrecognized!!! like there's compilation error or web.config missing!



please help - the problem is in post subject.

I have lots of warnings with following text:

"Warning 10 Element 'HyperLink' is not a known element. This can occur if there is a compilation error in the Web site, or the web.config file is missing. C:\Users\Pavel\Documents\Visual Studio 2010\WebSites\BioWebSite\ToScientist.aspx 26 18 C:\...\BioWebSite\" 

But web.confg is there! And there's no compilation error!

Site builds just fine. And If I upload it to my hoster - it works!


But with all these errors I cant add controls to pages - VS2010 adds hyperlink without ID, and intelisens stoped to work.

Strange, but in my other project (web-application) I have no such difficuty.

why runat="server" attribute is required for ajaxcontroltoolkit controls?

the doubts i have may looks silly,i started my carrier in dotnet recently,1)we are calling them as client side controls,then what is the need for runat server attribute?2)<asp:Button ID="Button1" runat="server" Text="Button" /> <asp:ConfirmButtonExtender ID="Button1_ConfirmButtonExtender" runat="server"              ConfirmText="Really?" Enabled="True" TargetControlID="Button1">  </asp:ConfirmButtonExtender>when i execute the above code,i observed that in status bar message as "connecting to localhost",if they are client side controls what  is the need of going to local server,why it is happening?Thanks in advance.

Binding Expressions in server controls

Hi i'm trying to do the following:<asp:LinkButton ID="lnk" runat="server" OnClientClick='func(<%# Request("ID") %>)'>click</asp:LinkButton>func is a javascript function that takes 1 argument "ID". but this gets rendered as the following:<a onclick="func(&lt;%# Request(&quot;ID&quot;) %>);" id="lnk" href="javascript:__doPostBack('lnk','')">click</a>instead of onclick="func(1)" for example.the problem is that the < is rendered as &lt; and " is rendered as &quot;Is there a way to solve this problem?thank you.

Putting Server controls on top of each other

My problem is this...I have 2 server controls. A control that we can call 'SwapImageControl' where the user can change images via AJAX and a 'DoctorNameControl' where a user can change the dr. name via AJAX... The 'SwapImageControl' has a image control in it that will span over the entire table row... I am wanting to place the 'Doctor Name Control' over the 'SwapImageControl' so the user can still see the DoctorNameControl label. I tried using opacity on the Dr. Control in css but it looks terrible...Thanks in advance,Travis

VS 2010 Stopped recognizing server controls

I have a zillion warning messages when I view my webform "Validation (): Element 'menu' is not supported" and every "<asp:WhatEver" tag has a green squiggly line under it.It looks like this:I'm using VS 2010 Pro, and have tried reinstalling it.

Initialize background image url in css file into custom server controls



i registered an image in AssemblyInfo.cs like this:

[assembly: WebResource("MyControl.Icons.bold.png", "image/png")]


protected override void RenderContents(HtmlTextWriter output)
            output.Write("<p class='BoldButtons' onclick='event4()'>event4 </p>");

now i want to initialize that image in css file for background-image but it dose'nt work.

my css file is:

	background-image: url("MyControl.Icons/font_bold.png");
	border: 0px; 
	height: 21px; 
	width: 21px;

i also try with this :

background-image: url(<%=WebResource("MyControl.Icons.bold.png")%>);

but it dose'nt work.

please help me? 

server controls inside asp:wizard, doesnt render html when step is not first..


I have a server control which consists of a gridview with custom navigation&information capabilities and with javascript functions to highlight the selected grid items or highlight when mouse over event occurs.. (full tested outside asp:wizard)

I'm trying to use that server control inside a template wizard step, when I drop such server control in the first step of the wizard everything goes ok.

When I insert even a blank step previous to the step which contains the server control, the javasript code of the server control is not rendered at all, the page doesn't fail during load but until I go with mouse over an item of the grid for instance.

When I check the rendered HTML I can see no HTML, nor javascript events of this server control where rendered, neither the implementation nor calls to javascript, but even rarer what is there visible in the grid for ie, even the other components of the server control, are not in the "view source code" content.  

I seems it was sent to the client, even showed, but truncated in some phase..

Thanks in advance for your comments,


data bound server controls


Can some one explain when to use the following databound controls.

  • GridView
  • DetailsView
  • FormView
  • DataList
  • ListView

For displaying single record at a time, i can use any of the DetailsView, FormView. So why do we need two of them.

Same for GridView, DataList, ListView. Are there any specific advantages of them.

Are there any specific scenarios in which i have to use a particular one only.

Client side script for server side controls


I have a whole table full of checkboxes each of which is associated with a label.  Both checkboxes and labels have runat="server".  What I'd like to do is to write a small script that will make visible or hide the label depending on the check state of the checkbox.

function ShowHideLabel(cbControl, lControl)
    lControl.Visible = cbControl.Checked;


<asp:checkbox id="cb1" runat="server" text="CheckBox 1" OnClick="?" />
<asp:label id="l1" runat="server" text="I am visible" />

What do I need to put in OnClick for this to work?



Unknown server tag - controls not rendering in visual studio 2010 design surface


I added a visual web part item to my solution.  I'm looking to drag some controls on to the design surface from the toolbox but they're not there.  For example, linqdatasource control and datapager control.  I tried to create them in the markup up but all I get is 'cannot render control' or 'unknown server tag.'

At the top of my .ascx file I have:

<%@ Assembly Name="$SharePoint.Project.AssemblyFullName$" %>

<%@ Assembly Name="Microsoft.Web.CommandUI, Version=, Culture=neutral, PublicKeyToken=71e9bce111e9429c" %>

<%@ Register TagPrefix="SharePoi

using dropdownlist server controls in webforms


I have created a registration webpage with password fields to enter and also some dropdownlist server controls to select from the list. When i change some items from the dropdownlist or when i check the checkbox in the webpage, the password entered in the password textbox gets cleared. How to get rid of this? I have set the autopostback property  of the checkbox and also the dropdownlist server controls to true.

Provide me the solution

Thanx in advance

Deploying Visual Web Part with Custom Server controls


I created a Visual Web Part with VizStudio 2010. In this web part I have a custom server control that exists in a project I added to the solution.


When I deploy from the menu can I tell Studio to deploy the Custom Library or do I install that manually?


It builds fine, but when I add the web part to a web part page I get an exception that the assembly cannot be found.

ASP.NetWindows Application  .NET Framework  C#  VB.Net  ADO.Net  
Sql Server  SharePoint  Silverlight  Others  All   

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend