?
Solved

double quotes in c#

Posted on 2006-05-05
5
Medium Priority
?
574 Views
Last Modified: 2012-05-05
Page.RegisterStartupScript("ScrollPanel", "<script language=""javascript"">document.getElementById('" & myControl.ClientID & "').scrollIntoView();</script>")

translate this please someone into c# focusing on the double quotes near the word javascript, its giving me a headache.
0
Comment
Question by:joshuadavidlee
5 Comments
 
LVL 16

Expert Comment

by:Edwin_C
ID: 16619399
Page.RegisterStartupScript("ScrollPanel", "<script language='javascript'>document.getElementById('" & myControl.ClientID & "').scrollIntoView();</script>");

You can use single quote in javascript.

I prefer a clearer way for building string.

Page.RegisterStartupScript("ScrollPanel", String.Format("<script language='javascript'>document.getElementById('{0}').scrollIntoView();</script>", myControl.ClientID));

Edwin
0
 
LVL 11

Expert Comment

by:TornadoV
ID: 16619409
Try this:

add Using System.Text;

StringBuilder sBuilder = new StringBuilder();

sBuilder.Append("<script language='javascript'>document.getElementById('")
sBuilder.Append(myControl.ClientID)
sBuilder.Append("').scrollIntoView();</script>")

Page.RegisterStartupScript("ScrollPanel", sBuilder.ToString());
0
 
LVL 6

Accepted Solution

by:
nehaya earned 2000 total points
ID: 16619419
put it like this: add \ before quotes where " is meant to be inside the string..
Page.RegisterStartupScript("ScrollPanel", "<script language=\"javascript\">document.getElementById('" & myControl.ClientID & "').scrollIntoView();</script>");

and for C# , replace & with +


Regards,
Nehaya
0
 
LVL 10

Expert Comment

by:aki4u
ID: 16619871
C#

Page.RegisterStartupScript("ScrollPanel", "<script language='javascript'>document.getElementById('" + myControl.ClientID + "').scrollIntoView();</script>");
0
 

Author Comment

by:joshuadavidlee
ID: 16619878
ok so many good answers umm i will give to the guy who said replace quotes with the slash cause it answers the question more accuratly even though javascript taking single quotes is nice and elegant alos, thanks for answers
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I recently went through the process of creating a Calendar Control of events with the basis of using a database to keep track of the dates that are selectable, one requirement was to have the selected date pop-up in a simple lightbox.  At first this…
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Integration Management Part 2
Despite its rising prevalence in the business world, "the cloud" is still misunderstood. Some companies still believe common misconceptions about lack of security in cloud solutions and many misuses of cloud storage options still occur every day. …
Suggested Courses
Course of the Month17 days, 8 hours left to enroll

829 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question