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

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

single quote in control.Attributes.Add

Posted By:      Posted Date: October 24, 2010    Points: 0   Category :ASP.Net

I'm trying to add a javascript event on my textbox:


TextBoxTesto.Attributes.Add("onblur", "javascript:onblur_text(this.id, '" & specifictext & "');"))


The rendered html replaces single quotes with "'".

Furthermore I've seen the code of dropdownlist with postback and the rendered html code for them is like this:


onchange="javascript:setTimeout('__doPostBack(\'controlname\',\'\')', 0)"


This happens with VS 2010 and not VS 2008.

Nevertheless it seems to cause no problem and everything works well, even if I'd prefer to the VS 2008 approach because I'm afraid that some old browser could show some unwanted behaviour.  


View Complete Post

More Related Resource Links

XML Column containing single quote causes replication error

We have SQL Server 2005 transactional replication set up, and some of our tables have XML datatype columns.  We have run into an issue with the following error in the publication: Incorrect syntax near 's'. (Source: MSSQLServer, Error number: 102) Get help: http://help/102 Looking at the distribution database, I was able to extract the offending command, and it turns out that the XML column has a single quote (') embedded in it, and the command that was generated for inserting the row into the subscriber table has bad syntax because of the single quote (i.e., it is not escaped).  One interesting note is that the single quote happens to also show up in a non-XML column, and the command segment for that column was generated correctly (it was escaped). Is there a workaround / solution for this?

how to double quote a control?

 How would I put quotes on the DataLink control so it outputs "\ \computer\folder" (i put a space in there between the \\ so it would show up) instead of just \\computer\folder   it generates a link but if the folder name has a space it in the link breaks so i am trying to put double quotes on it so it creates a link even if there are spaces.  Dim DataLink As New TextBox DataLink = FormViewDC1.FindControl("CDR_Data_LinkTextBox") mail.Body = "Your CDR ID#" & cdrID.Text & " status has been updated to: " & Status.Text & "<br /><br />" & "Data Location:<br />" & DataLink.Text & "<br /><br />" & "Comments:<br />" & Comments.Text & "<br /><br />This is an automatically generated email, please do not reply."  

Problems with single quote character when attempting to export data from SQL Server

Hi, I am attempting to use the following query, which works fine when run in sql server management studio, to export data: SELECT             '1',             isnull(left(DISTRICT,1),' '),             isnull(left(CTV,2),'  '),             isnull(left(CTV2,5),'     ')           FROM [CensusData].[dbo].[MainQuestionnaire$] The export command follows: EXEC xp_cmdshell 'bcp "SELECT             '1',             isnull(left(DISTRICT,1),' '),             isnull(left(CTV,2),'  '),             isnull(left(CTV2,5),'     ')             FROM [CensusData].[dbo].[MainQuestionnaire$]" queryout "C:\bcptest.txt" -T -c -t -S "MYSERVER"' The error is: Incorrect syntax near '1'. I believe that the problem is with the single quote characters but don't know how to fix it. I am using SQL Server 2005 Express edition. Please help.

How to replace ' to single quote in XSLT


I have a DataView webpart in my Sharepoint  page.And I converted it to XSLT view for conditional formatting.My requirement is i need to get the Text of a column (of DataView )in a correct format with the property  disable-output-escaping="no" condition.Here Iam explaining the scenario my actual text is

 This is text of dvcolumn at share's Desk .But I am getting it as
 This is text of dvcolumn at share&#39;s &amp; Desk. I need to replace apostrope(or single quote ()')  at  &#39; and  space at &amp; .I used truncate function at DataView's EditFormula option .But I dint get it properly can any one help me out in this??

How to exclude single quote?




I have a string like 12 ju 'kold dsd' 15g.

And I wanna get 4 separated strings: 12, ju, kold dsd & 15g.

I have implemented next pattern: ([0-9a-zA-Z:=\|]+)|'[ 0-9a-zA-Z:=\|]+'

It has given next result: 12, ju, 'kold dsd' & 15g.

How to exclude quotes by means of RegExp?

Preventing cross-site scripting and encoding a single quote


I'm trying to prevent possible cross-site scripting attacks for our internal use app (but available publicly outside the firewall).

One feature of our app is a javascript based breadcrumb that keeps track of prior urls (via nice titles). Everytime, a new page is loaded in the current workflow, when that page renders as the browser, it includes some javascript (generated server side in C# and put into the page) to add itself to the breadcrumb trail. Currently, the url that is launched is given directly to that javascript function. However, if that url contains a single quote it is possible to inject some custom javascript, ie, one would just need to append    ');alert('yeah!');       to their url.

I tried encoding/escaping but they skip the single quote. This is a case where I'm just passing the url through. But theoretically, if an attacker tricked somebody into launching his site when they are in ours, then I guess he could get script to execute in our page.

I don't see any method that takes a COMPLETE url and encodes/escapes JUST the parameters. So for now, I'm tearing down the url, and rebuilding it from the ground up, but encoding the parameter names and values.  This basically prevents the script from running, but I do still end up with at least a javascript error because of

How to save a multiple user control to a few single record text?

I have a list with people pecker control that admits multiple users.
I like to have another list with one record for each user in the control that loaded before.
Is there any way in InfoPath or in a workflow to use something like FOR EACH to take one by one user in a control and write/update records after that?
Thank in advance

information on asp.net control attributes



where is the list or documentation to know what styles can be applied for the asp.net controls like datagrid, detailsview, pagerstyle, etc.

Also where should I get information por setting on the alternate data item style? when I have a details view I would like to have a row with a different color the odd row for example

Thanks :)

using table variable in single quote



I searched over internet but i couldn't find. How can i use table variable in single quote here some of code that i can do and i can't

for example if i can write like this it will work

declare @table table ([name] varchar(20))
insert into @table values('ahmet')
select * from @table
but if i can write like this does not work
exec('select * from ['+@table+']')
I can use any variable for table name like
declare @tableName varchar(20)
set @tableName = 'sampleTable'
exec('select * from ['+@tableName+

Is is possible to pre-compile a single control or a page ...



I am working on an asp.net web site project with a large codebase.  Publishing the site takes about 30 minutes. Since I have to do this twice a day, this takes up too much of my time. Is there a way to publish only changed pages or controls. Visual studio does give an option to compile a single page or control by right clicking on it and selecting "build page". 

Is it possible to publish a single page, maybe through command line.


Javascripts single quote problem


Hi ,

I am calling a popup from anchor inside a gridview.

<a href="javascript:ShowSiteVirtualProfile('<%#Eval("Site").ToString().Replace("'", "\'")%>','<%#DataBinder.Eval(Container.DataItem,"Query").ToString().Replace("'", "\'")%>')"><%#DataBinder.Eval(Container.DataItem,"Site")%></a>

Its works fine. But a single quote in the text popup is not working.

Please give me a solution what I need to do now.

Replacing ampersand and single quote in XSLT


Hi All,

I want to replace single quote and ampersand in XSLT of data view web part.
I tried to use translate function. But when i do a translate of &amp;#39; then &amp; is also getting replaced. Could some one help me on this.


Activate Form/Process menustrip or toolstrip control with Single Click


I am trying to make my form process the form activate and the ToolStrip or MenuStrip selection with a single click.  Currently, if a form does not have focus and you mouse over the ToolStrip or MenuStrip options they highlight like you can click them.  Only you have to click once to activate the form and again to activate the option you are over.  Does anyone know of a way to do this in a single click?


I have found this as a solution http://www.codeproject.com/KB/menus/UpgradeToMenuStrip.aspx?msg=2615988.  It does work however; it breaks the C++ form editor.  Is there another way to do this?


Thank You

Single control template for buttons


I have created all my buttons such that they are made up of a rectangle and a path figure. The aim is so I should be able to apply a same control template triggers to all of them - for IsPressed, IsMouseOver and the standard look.

I want to be able to pick the actual template ('path' figure for each button) from an external source and not embed it within the template definition. Otherwise, I am having to define same trigger behaviors for each button separately.

Any suggestions?


In the example code below, I want to put several 'Path' or the entire 'Grid' outside of the style.

<Style x:Key="MyButton" TargetType="{x:Type Button}" BasedOn="{x:Null}"

Can I use a single DynamicFilter control in a custom page?


Is it possible to use a single DynamicFilter control in a custom page, similar to the way that I can use a single DynamicControl field in a custom page?  

For example I can do this (I have customized the Edit page to be a wizard with fields like this in different steps) ...

<asp:DynamicControl ID="DynamicObservationDate" runat="server" DataField="ObservationDate" />

But when I do this, nothing shows up on the page.

        Observation Date: <asp:DynamicFilter runat="server" ID="ObservationDateFilter" DataField="ObservationDate" />

Do I need to "initialize" the DynamicFilter somehow for this to work?  

Thank you!

Strange problem, unable to insert single quote (already add in an extra single quote) for one partic

I have a very strange problem, I can update the table with single quote, but I cannot insert single quote. It only happen for this particular table in the database. Is there any suggestion on what I should look at?

I had already added in an extra single quote in my sql statement, something like this:

insert into Table_1 VALUES ('hello''s world','xxx')

Single web control that behaves both as button and Image button control


Hi Everyone,

I am planning to create/use a webcontrol , the behaviour of this control should be in such a way that , it should act as a button or Image button based on the client using that control. I mean if the client wants to use that control as ImageButton it should expose him properties of Imagebutton control like (Image Src, image align etc..), if he wants to use that control as Button it should expose him only button properties and it should not expose any Imagebutton related properties. is it possible to implement such control? i guess i can try generics, but really i am not sure whether i can use generics to solve this problem. or there any other alternatives other than Generics..?

Thank you,


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