.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

Javascripts single quote problem

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

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.

View Complete Post

More Related Resource Links

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')

Generating MS Word doc from mht file gives smart quote problem


I have a word document to be generated using ASP.Net/VB.net.

So I have a word document template saved as .mht file on the web server.

In my ASP.Net code,I read this mht file content and replace certain string line Description$$ with the actual description from the database.Then save this content as .doc file.

This works fine but shows a box symbol when I have smart quotes " (not this one as I cannot type it here.The double quote which you see in MS Word,the slanted double quote).

I dont know how to make my word doc generated, show the exact double quote as in MS word.

If any of you have any idea of this please reply.

Thank you

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?

Problem with ListView and SelectionMode="Single"

  I have the following XAML: <Grid>       <ListView SelectionMode="Single" Height="100" HorizontalAlignment="Left" Margin="26,118,0,0" Name="listBox1" VerticalAlignment="Top" Width="120">       <ListView.View>       <GridView>       <GridViewColumn Header="Test"/>       </GridView>       </ListView.View>       <ListViewItem>Test</ListViewItem>       <ListViewItem>Test</ListViewItem>       <ListViewItem>Test</ListViewItem>       <ListViewItem>Test</ListViewItem>       <ListViewItem>Test</ListViewItem>       <ListViewItem>Test</ListViewItem>       <ListViewItem>Test</ListViewItem>       </ListView>       </Grid>       Just a stock ListView with SelectionMode="Single". Isn't SelectionMode="Single" supposed to be single selection mode? There seems to be a lot of weird stuff with the Ctrl-Key. I tested the same behavior in a standard W

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

Profile synchronization problem - can successfully import single users but not from a group - can yo


I can successfully import a single user into SharePoint 2010 from AD (proves settings permissions are correct) and the number of user profiles increases and I can locate the user including profile data from active Directory. But when I try to import an Active Directory global security group no users get migrated. In fact the single users profile gets deleted.

Can somebody explain whether it is possible to migrate users into SharePoint 2010 from with security groups in Active Directory?

Also when I retried to import the group of users it deleted the single user that I had successfully imported, I didn’t think this was possible, I ran an incremental synchronization, i need to import roughly 2000 users and was going to do it in stages to make sure all users were imported but if the process can remove users then each sync run could be adding users and removing users, how will I ever keep track?

Below is the synchronization run report, are there logs files that could give me more information?

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+

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.


Problem filling labels with table data outside datalist using single call to db


On a single page, I'd like to fill 2 hyperlink controls as well as a datalist control with table data using one call to the database. The page looks like this:

<div id="PageContent">    
      Please select the district you wish to view below.</p>
      <asp:DropDownList ID="ddlDistrict" runat="server" CssClass="textbox" 
        DataTextField="DistrictName" DataValueField="DistrictId" AutoPostBack="True" 
    <p><asp:label ID="lblDistrictAbbrev" runat="server" Text="District Abbreviation: " />
      <asp:hyperlink ID="hyperlinkDistrictName" runat="server" 
        Text='' NavigateUrl="~/Contact/NationalCouncil.aspx" 
        Font-Bold="True" />
    <p><asp:label ID="lblDistrictCouncillor" runat="server" Text="District Councillor: " />
      <asp:hyperlink ID="hyperlinkCouncillor" runat="server" 
        Text='' NavigateUrl="~/Contact/NationalCouncil.a

single quote in control.Attributes.Add


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 "&#39;".

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


onchange="javascript:setTimeout(&#39;__doPostBack(\&#39;controlname\&#39;,\&#39;\&#39;)&#39;, 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.  


Single User MySite Creation problem

Yeah... So I left the company I work for about 8 months ago, and came back to it about 2 months ago.  During my absence, my teammates deleted my AD account (as they should have).  Let me preface this by saying that MySite creation works for everyone else but me.

When I click on MySite I get the create My Site page, I can choose my language, but after pressing OK, I get this error:  "There has been an error creating the personal site. Contact your site administrator for more information."

I'm really not sure where to start on this one...  And am willing to give up quickly and just rename my account.  Does anyone have any ideas before I go that route?


Problem to group radio button across gridview rows

In general no one can easily group or make a single selection from radio button list inside gridview rows. There are a lot of way to make a single or unique selection from list. Here i want to share how i can address this problem in the most easiest way. Googling the problem most of the cases i saw the grouping in horizontal way. Thats why i tried to group the radio buttons in vertical manner. Let i have a requirement like below:

Application Architecture in Windows Forms 2.0-Single-MDI Applications

Consider an MDI application like Microsoft Excel; files opened from the file system (by double-clicking) are all opened as separate child windows within the parent Excel window.7 For the first instance of an MDI application to open a new child window to display the file that was passed to the second instance of the application, the second instance must be able to communicate with the initial instance.

Regrading Sharpoint 2010 problem and solutions

We can write your question and problem on this blogger.you get ans.use.
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