Link to home
Start Free TrialLog in
Avatar of joshuadavidlee
joshuadavidlee

asked on

double quotes in c#

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.
Avatar of Edwin_C
Edwin_C
Flag of Hong Kong image

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
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());
ASKER CERTIFIED SOLUTION
Avatar of nehaya
nehaya

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of aki4u
aki4u

C#

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

ASKER

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