.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

unterminated string literal issue in asp.net onclick

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

<img width="15" height="15" border="0" onclick="_s.my.letters.action.fillDataForMenu(this, {id:'26308409', title: 'hi''})" src="http://media.newjobs.com/mm/redux/cover-letter/flyoutPoint.png" alt="action">

this is code generated for the image button for my which looks like

<img height="15" border="0" width="15" alt="action" src="http://media.newjobs.com/mm/redux/cover-letter/flyoutPoint.png" onclick="_s.my.letters.action.fillDataForMenu(this, {id:'<%# ((SimpleLetter)Container.DataItem).ID %>', title: '<%# ((SimpleLetter)Container.DataItem).EncodedTitle %>'})"/>

but this code is giving the Error as "unterminated string literal" in javascript if i include the single quote in the Title Text.....(')

remaining cases its working good

View Complete Post

More Related Resource Links

Really Long JSON String wraps to multiple lines in source, creates unterminated String Literal error


I have an app that writes a JSON object to a string and registers a script block onto the page that client-side javascript then uses to build interface components.  I found that the javascript is working fine when the data set is small, but on large datasets, when I view the source, the JSON object string takes up a few lines because it is so long.  I didn't think anything of it until I started manually trying to recreate the "Unterminated String Literal Error", only to find that the error goes away when I format the JSON string to be a little more "readable".  What I discovered is that this does away with the automatic new line wrap, making the error go away. 

Make Sense?  Is there anything I can do about this?

Weird Issue with the MOSS Search : FileExtension metadata object type instead of string

Hello, We 've got a strange issue with the search and especially with the FileExtension metadata. when we make a query on the search engine, we receive for the FileExtension metadata an unexcpected result. here is a printscreen showing the issue. http://cid-53eee937847a625e.photos.live.com/self.aspx/Public/Untitled.jpg as you can see the Type of the FileExtension is object and it should be string and I checked the type of the object and it's System.String[] the element at the index 0 contains the value! what's wrong ? thx in advance


Hi all,Here's some simple code<a href='<%= string.Format("../Print/Print1.aspx?withParameter={0}", Para )%>'>HyperLinkText</a>and it works well. so i guess i can write anything like this, so i wrote a test:<input type="button" value="Btn1" onclick='<%= string.Format("window.open('','_blank')") %>'/> <input type="button" value="Btn2" onclick="window.open('','_blank')"/>However, Btn1 does not work.. for some reason i have to NOT to use server control, so i wite it in inline-code style,why the first hyperlink work well, but Btn1 fails?could anyone tell me?thank you~

Can't pass string to javascript function(unterminated string)

Hello,I have a problem. I can't pass string like this  ": Mar 15 2004 12:00AM  Refnr: 20040315!m>N0"to javascript function because I have symbols like these >, <, % ?tc.Situation:I have a Grid and I have column with DataItemTemplate,Within my dataitemtemplate I have <a href="javascript:void(0);"  onclick="ShowAccountStatementNote(document.getElementById('<%= lblHiddenNoteText.ClientID %>').value);" >                                                          Bekijken...                                                      </a><a href="javascript:void(0);"  onclick="ShowNote('<%# EncodeStringToHTML(Eval("Note")) %>');" > Notes </a>ShowNote function just show popup with text = NoteEncodeStringToHTML do Server.HtmlEncode(); But It doesn't help because even if we change text on server .... e.g. "dfdf%" convert to "dfdf&#37;"  anyway on client it becomes again "dfdf%" and problem still exists.On clien

.NET 4 Performance Issue String IndexOf



I have a performance issue with the new dot net 4.0 framework.

When i use the function String.IndexOf(string, stringcomparison.ordinalignorecase) my execution time is much higher than framework 3.5 (i had 30ms in a loop for 3.5 and 210ms in framework 4)

All other StringComparison mode are really good in framework 4.

Is there an explanation?

Query String Issue


Hello everyone,

I just started with learning MVC so please bear with me. I have a grid displayed on my Main page(Index) and when I click on the Details Link for a particular row(suppose productID=1) it should invoke the following action otherwise redirectToAction("Index"):


        // GET: /Home/Details
        public ActionResult Details(int? ProductID)
            if (!ProductID.HasValue)
                return RedirectToAction("Index");
                return View("Details");

The ProductID in my case is always Null and it actually ends up redirecting back to the main page as expected. Why is that happening. Somebody please help.

Thank You

Connection String issue?


Hey guys.

I'm working on an MVC2 app and my solution consists of a MVC2 Project, and Class Library Project that holds my EDMX.

My MVC2 project references the class library project and for some reason when I compile I get this error.

I'm suspecting that it's got to do with the lack of a ConnectionString in the MVC2 Project, but shouldn't that have come across into the Web.Config when I added reference to the Class Library (I noticed this happen once before?), plus I figured that the MVC2 project wouldn't need the Connection String because the Class Library is handling all the connections?

Any help would be appreciated!

System.ArgumentException: The specified named connection is either not found in the configuration, not intended to be used with the EntityClient provider, or not valid.

Line 79:         MyBase.New("name=NameEntities", "NameEntities")

Repeater DataBind issue (OnClick of Button)


I have a repeater with a webusercontrol in it.  The WebUserControl has some labels and TextBoxes in it.

It binds on PageLoad just fine.  However the databinding does not work in a button's OnClick event. (The button is not in the repeater control).  The datasource is fine, I've stepped through and the data is good, just something fails as though each data row is blank (for example, if the repeater is supposed to have 10 items, it does, they are just empty.

              <asp:Repeater ID="Repeater1" runat="server" >

                    <div class="HoursRow">
                        <uc1:webusercontrol Data='<%# Container.DataItem %>' id="WebUserControl1" runat="server" />

Any help would be appreciated.

GridView row onclick issue



I'm trying to add multiple statements to a onclick attribute of a Gridview row:

protected void GridView1_RowCreated(object sender, GridViewRowEventArgs e)
if (e.Row.RowType == DataControlRowType.DataRow)
string script = (Session[SessionKeys.MarkblokSagNoegle] != null)
? "return confirm('Der er allerede en sag under behandling hvis du genoptager en anden vil denne sag forsvinde!'); "
: "";

script += Page.ClientScript.GetPostBackEventReference((Control) sender,
e.Row.RowIndex)) + ";";
e.Row.Attributes.Add("onclick", script);

Something must be wrong with the way I concat the string 'script' with the statement that makes the row selectable. when the session var is null, then the Page.ClientScript statement goes through and the row will be selectable, but when the session var is NOT null and as a result, the whole statement contains the 'confirm' part, the the confirmation dialog pops up but nothing else happenes upon confirming.

What's wrong with the "script += Page.ClientScript.GetPostBackEv..." part?


Connection String issue: Keyword not supported: 'data source'.


I have three connection strings for my web application (ASP.Net) as MVC2 provides by default.

Bar the locations and the names, the syntax is identical, but in the second connection string, it keeps returning "Keyword not supported: 'data source'." EVEN THOUGH IT'S IDENTICAL. D:

Please help! I've tried changing the Syntax to include a "Metadata" tag, still didn't work!

How to Encrypt Query String Parameters in ASP.NET

Encrypt Query String Parameters in ASP.NET.u can send secure data one page another page u can also use query string to encrypt

Connestion string create any database server

This links important to how to create connection string to any data base sever.

SQL Connection String

We can learn or know how can we connect the database from our .net. This will help for freshers or .NET beginners!

Built-in Functions - String Functions

String functions let you extract various portions of character strings, change the case of strings, concatenate and reverse strings and perform many other types of manipulations. All built-in string functions are deterministic with the exception of CHARINDEX and PATINDEX

abstract away the source of the connection string using a class with a static property.

ASP.NET provides a configuration system we can use to keep our applications flexible at runtime. In this article we will examine some tips and best practices for using the configuration system for the best results.

The element of a web.config file is a place to store connection strings, server names, file paths, and other miscellaneous settings needed by an application to perform work. The items inside appSettings are items that need to be configurable depending upon the environment, for instance, any database connection strings will change as you move your application from a testing and staging server into production.

Let's abstract away the source of the connection string using a class with a static property.

IsapiModule Error 500 Issue


I am about exhausted trying to figure out this error:

HTTP Error 500.0 - Internal Server Error

Description: The page cannot be displayed because an internal server error has occurred.

Error Code: 0x8007007b

Notification: ExecuteRequestHandler

Module: IsapiModule

Requested URL: http://localhost:80/ReportServer

Physical Path: c:\Program Files\Microsoft SQL Server\MSSQL.2\Reporting Services\ReportServer

When I enable Failed Request Tracing Rules and view the log output I am supposing that the actual problem is in the 2nd call where there are 2 backslashes before the actual filename in the specified path:


CALL_ISAPI_EXTENSION DllName="C:\Windows\Microsoft.NET\Framework\v2.0.50727\\aspnet_isapi.dll"


highlight string


i am looking for a function that takes two string parameters 

str1 = "hello how are you today mr john"

str2 = "how today"

and in return it shoud highlight the words "how" and "today".

Any ides? I prefer if its possible using reg expression...Thanks

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