473,385 Members | 1,736 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Help with syntax

I am working with the asp.net blog posted at msdn by marco bellianso, msdn
october 2003.

The problem is that the javascript (ToggleDivState) to show and hide
comments does not work in browsers other than ie. So I have another
javascript that works across most browsers. The script I am using needs a
single quoted div

To test my script I inserted the following line where I have hardcoded the
div (div3).

<a href="javascript:ShowHide('div3');">show layer</a>

What I need is to add single quotes to the following code (div" &
Container.DataItem(MessageId") & ") . The full line is below.

<asp:HyperLink Runat="server" Visible='<%#
Container.DataItem("CommentsCount") > 0 %>'
NavigateUrl='<%# "javascript:ShowHide(div" & Container.DataItem("MessageID")
& ");" %>'>View</asp:HyperLink>
Everything I try gives a server tag is not well formed error.

Thanks
arlie


Nov 18 '05 #1
4 1386
arlie wrote:
<a href="javascript:ShowHide('div3');">show layer</a>

What I need is to add single quotes to the following code (div" &
Container.DataItem(MessageId") & ") . The full line is below.

<asp:HyperLink Runat="server" Visible='<%#
Container.DataItem("CommentsCount") > 0 %>'
NavigateUrl='<%# "javascript:ShowHide(div" & Container.DataItem("MessageID")
& ");" %>'>View</asp:HyperLink>
Everything I try gives a server tag is not well formed error.

Thanks
arlie

Create a function in your codebehind and then call it in the bind (watch
line wrapping)..in the codebehind

Function CreateJScriptCall(messageID as Object) as String
return "javascript:ShowHide('div" & Convert.ToString(messageID) & "');"
End Function

Then your tag above uses

NavigateUrl='<%# CreateJScriptCall(Container.DataItem("MessageID")) %>'

--
Craig Deelsnyder
Microsoft MVP - ASP/ASP.NET
Nov 18 '05 #2
Thanks Craig,

Still have a problem.

I created the fuction in my default.aspx.vb file. Saved the file. Changed
up the line in the default.aspx. Rebuilt the solution. When I view it in
the browser I get Name 'CreateJScriptCall' is not declared. This is only my
second project in asp.net. Moving over from asp.

thanks,
arlie
"Craig Deelsnyder" <cdeelsny@NO_SPAM_4_MEyahoo.com> wrote in message
news:uf**************@TK2MSFTNGP11.phx.gbl...
arlie wrote:
<a href="javascript:ShowHide('div3');">show layer</a>

What I need is to add single quotes to the following code (div" &
Container.DataItem(MessageId") & ") . The full line is below.

<asp:HyperLink Runat="server" Visible='<%#
Container.DataItem("CommentsCount") > 0 %>'
NavigateUrl='<%# "javascript:ShowHide(div" & Container.DataItem("MessageID") & ");" %>'>View</asp:HyperLink>
Everything I try gives a server tag is not well formed error.

Thanks
arlie

Create a function in your codebehind and then call it in the bind (watch
line wrapping)..in the codebehind

Function CreateJScriptCall(messageID as Object) as String
return "javascript:ShowHide('div" & Convert.ToString(messageID) & "');"
End Function

Then your tag above uses

NavigateUrl='<%# CreateJScriptCall(Container.DataItem("MessageID")) %>'

--
Craig Deelsnyder
Microsoft MVP - ASP/ASP.NET

Nov 18 '05 #3
arlie wrote:
Thanks Craig,

Still have a problem.

I created the fuction in my default.aspx.vb file. Saved the file. Changed
up the line in the default.aspx. Rebuilt the solution. When I view it in
the browser I get Name 'CreateJScriptCall' is not declared. This is only my
second project in asp.net. Moving over from asp.

thanks,
arlie


Hmmm...that should work. Forgot to say the function must at least be
Protected as well. I think not specifying Protected Function makes it
ok, but you should pry specify Protected Function instead of Function
like I had in the code-behind.....are you sure the default.aspx.vb is
declared as the codebehind? Check the directives at the top of the
..aspx file and make sure they point at this class/file. Also, check for
typos in the tag in the .aspx....looks fine to me....

--
Craig Deelsnyder
Microsoft MVP - ASP/ASP.NET
Nov 18 '05 #4
Craig,

My aplogies I had a typo. Plus we did not need to add Protected.

Another request for help?

The code posted at msdn also has the same problem when it comes to posting a
comment.

Here is the Javascript that shows the comment box when a user clicks on
'Post your own comments'

function ShowCommentBox(msgID)
{
// set the ParentMessageID hidden field with the ID of the
message being commented
document.forms[0].ParentMessageID.value = msgID;
// expand the CommentBox div
ShowCommentBox2();
}

function ShowCommentBox2()
{
// expand the CommentBox div
CommentBox.style.display = "";
// jump to the CommantBox, so that it becomes visible even if
the page
// is very long and the user is currently at the top of it
window.location.href = '#CommentBoxAnchor';

I wanted to use the same javascipt that I used before to showhide comments

function ShowHide(elementid){
if (document.getElementById(elementid).style.display == 'none'){
document.getElementById(elementid).style.display = '';
} else {
document.getElementById(elementid).style.display = 'none';
}
}
Here is the line in the default.aspx page:
- <a href='<%# "javascript:ShowCommentBox(" &
Container.DataItem("MessageID") & ");" %>'>
Post your own comment</a>

As you can see I have the same problem as before when I replace
ShowCommentBox with ShowHide and add a single quote to the line.

Why do they, msdn, post articles like this when they do not work across
multiple browsers? At least I'm learning. Just don't know enough yet to
solve problems like this.

thanks,
arlie
Nov 18 '05 #5

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

14
by: sam | last post by:
When I run this SQL query: SELECT u.*, o.* FROM users u, orders o WHERE TO_DAYS(o.order_date) BETWEEN TO_DAYS('2003-09-20')-10 AND TO_DAYS('2003-09-20')+10
5
by: Danny Anderson | last post by:
Hola- I didn't get any responses on a previous post, so I am trying to reword my problem and post compile-able code that exhibits the behavior I am describing. On the second iteration of the...
28
by: stu_gots | last post by:
I have been losing sleep over this puzzle, and I'm convinced my train of thought is heading in the wrong direction. It is difficult to explain my circumstances, so I will present an identical...
2
by: Erik | last post by:
Hi Everyone, I'm having real problems compiling some source for eVC4++. The errors I am getting are below: It all seems to be centred around winsock. If I move the afsock.h reference to before...
6
by: Scott Nixon | last post by:
New to Postgres 7.3 from 7.0. Am having some trouble with a query that worked in 7.0 but not in 7.3.....can't seem to figure out the syntax or find info about how to do this anywhere. ...
1
by: Rahul | last post by:
Hi Everybody I have some problem in my script. please help me. This is script file. I have one *.inq file. I want run this script in XML files. But this script errors shows . If u want i am...
6
by: toch3 | last post by:
i am writing a c program that is basically an address book. the only header we are using is #include<stdio.hwe are to use a global array, loops, and pointers. we are to have a menu at the...
1
by: ligong.yang | last post by:
Hi all, I got tortured by a very weird problem when I was using k. wilder's random generator class in my program. PS: wilder's generator class can be found at...
1
by: ligong.yang | last post by:
Hi all, I got tortured by a very weird problem when I was using k. wilder's random generator class in my program. PS: wilder's generator class can be found at...
1
by: mshroom12 | last post by:
Hello to all. I am having difficulty trying to do this Java project using Eclipse. The following is what I have to do. Election Day It's almost election day and the election officials need a...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.