ASP.NET 4 Parser Error - asp.net

I received a asp.net 2 to upgrade to .net 4. While most of it went well I'm stuck on a line that can't find a solution for it.
I get a Parser Error Message: The server tag is not well formed.
at this line
<li><a class="tooltip viewPolicyLink" rel="<%#Eval("key")%>"
title="<%#Eval("value")%>"
href="<%#ResolveUrl("~/Views/Pages/ViewPolicy.aspx")%>"
runat="server"><%#Eval("key")%></a></li>
What's wrong with it?

you have messed with "
try :
<li><a class='tooltip viewPolicyLink' rel='<%#Eval("key")%>'
title='<%#Eval("value")%>'
href='<%#ResolveUrl("~/Views/Pages/ViewPolicy.aspx")%>'
runat="server"><%#Eval("key")%></a></li>

Double quotes are nested in rel, title, href attributes.

you need to use single quotes when setting tag values that contain the Eval() expression. The reason being is the double quotes that Eval takes.

Try using single quotes for the attributes containing server-side commands:
<li><a class="tooltip viewPolicyLink" rel='<%#Eval("key")%>'
title='<%#Eval("value")%>'
href='<%#ResolveUrl("~/Views/Pages/ViewPolicy.aspx")%>'
runat="server"><%#Eval("key")%></a></li>

Related

Using # number sign in "each" Meteor Jade

Is there any difference between this code blocks ?
each users
span #{username}
and
each users
span {{username}}
one thing I've found #{} can't be used in quotes (")
The #{var} syntax should only be used in text: reference
Inside a text node you can use both {{spacebars}} and #{jade}
expressions but the last one is recommended:
template(name="leaderboard")
p Welcome #{player.name}

Ruby -- Escape Single quote in variable name

I have this: my_variable = "You\'re It"
I want to find it on the page in an a tag so if I do:
page.parser.xpath("//a[contains(text(),'#{my_variable}')]")
page.parser.css('a:contains("#{temp_account_name}")')
page.parser.css("a:contains('#{temp_account_name}')")
I get an error for all the above.
But if I do:
page.parser.css('a:contains("You\'re It")')
it works. The problem is I can't use this above and place a variable in there.
How do I escape a ' character when using a variable and parsing it from the page?
On the page the text I am searching for is You're It. So I added the escape character to my variable to match and find what is on the page.
Try unescaping all the characters:
my_variable.gsub /[^\\](\\)[^\\]/, ''
...I think this is asp.net? If so, use .replace("'", "''") . Interesting solutions also exist with Server.HTMLEncode, but that's more for URLS.

HTML:Server Tag Not well Formed

Hi all I get the Server Tag Not Well Formed error on the following line of code.
<a class="button"><span><input id="btnEmbedCodes" type="button"
value="Click for Embed Codes" onclick='javascript:window.open("%=ExternalLink%>","ExternalFeeds","height=575,width=675,
scrollbars=yes,overflow-x:hidden")'; Style="width:165px" /></span></a>
Please help me out. Thanks
window.open("%=ExternalLink%>"
In this starting "<" is missing. Seems like that is the problem.
It looks like you missed a < in the first argument of your javascript function
You are missing the opening bracket before ExternalLink
You have missed less than sign (<) before ExternalLink and also surround it with single quotes rather than double quotes.
Thanks.

replace html tag in html editor with specific string

hi anyone knows how to replace a html tag in a string with specific characters:
e.g.
string s1 = "<span style="italic">inluding <span style="bold">other</span> tags </span>";
string s2 = "<span style="italic">inluding </span><span style="bold">other tags </span>";
i want to replace "span" with "bold" to "bOpen" and "bClose" and to replace "span" with "italic" to "iOpen" and "iClose" in both c# and javascript.
thanks very much.
thanks for the response, i did use regular expression to do that: res = Regex.Replace(res, ".*?", replaceHtmlBold); but it cant match the nested tag and none-nested tag at the same time. could you help please?
JavaScript's String Object has a handy function that lets you replace words that occur within the string. So does C#.
Regular expressions are your friends here. I could give you the exact code for your problem, but then you'll miss the point of learning this technique. Here is an Introduction to Regular Expressions and there is this article "C# Regular Expressions". If you need more, Google is your friend.
Good luck!
PS: I realized now what the real problem is. I think you can get away with lookaround techniques and conditionals. Both are summarized here.

OnClick location Not Work

**this Line not work properly /r work but $siteurl/%s-%s.html not work i think problem of ("") or ('') please help me to repair it
printf("<a href='/r?%s' target=_blank onClick='window.open(location.href=$siteurl/%s-%s.html)>", $wurl, $myrow["wallpaperid"], $myrow["wallpapername"]);
Don't use double-quotes within double-quotes (unless you escape them properly):
<a onclick="location.href='http://google.com'">Click Me</a>
Note how I use single-quotes within my double-quotes. This keeps the statement from being abandoned prematurely.
You could have also written it like this:
<a onclick="location.href=\"http://google.com\"">Click Me</a>
But that makes it slightly less readable.
Your onClick attribute misses the trailing single quote. Here's what I think it should be:
printf("<a href='/r?%s' target=_blank onClick='window.open(location.href=$siteurl/%s-%s.html)'>", $wurl, $myrow["wallpaperid"], $myrow["wallpapername"]);
BTW: I had a hard time reading even this single line. Consider indenting your code to make it human-readable. Also, I recommend against using variable substitution (the $siteurl var in your string) when you are using printf anyway. I mean, use the same mechanism to do the same thing. Either use only var substitution, or use only printf formattng, not both. Example:
$html = '
<a href="/r?%s"
target=_blank
onClick="window.open(location.href=%s/%s-%s.html)"
>
';
printf($html, $wurl, $siteurl, $myrow["wallpaperid"], $myrow["wallpapername"]);
You're missing a single quote mark after .html)
Try:
printf("<a href='/r?%s' target=_blank onClick='window.open(location.href=$siteurl/%s-%s.html)'>", $wurl, $myrow["wallpaperid"], $myrow["wallpapername"]);

Resources