Newbie - Help with a string

J

Joey Martin

I am just trying to populate a HYPERLINK section and instead and it
linking to another window, I want to use javascript to open a window and
set a window size.

The first one just shows Click here and opens a windows. Perfect, except
I want to write some database results.

THIS WORKS
NavigateUrl="javascript:window.open('123.html',null, 'height=200,
width=400, status=yes, toolbar=no, menubar=no, location=no');
void('');"> click here</asp:HyperLink>


THIS DOES WORK ALSO-Note that I know have real text populating using
EVAL (KEYWORD LABEL).

NavigateUrl="javascript:window.open('123.html?catKeywords=',null,
'height=200, width=400, status=yes, toolbar=no, menubar=no,
location=no'); void('');"><%# Eval("KeywordLabel") %></asp:HyperLink>

THIS DOES NOT WORK. I want to write more variables that are passed into
the popup window.<%# Eval("KeywordLabel") %>

NavigateUrl="javascript:window.open('popsearch.asp?catKeywords=<%#
Eval("KeywordLabel") %>' height=200, width=400, status=yes, toolbar=no,
menubar=no, location=no'); void('');"> click here</asp:HyperLink>


Any ideas as to what I can do here???
THANK YOU SO MUCH IN ADVANCE!!!
 
A

Andrew Morton

Joey said:
I am just trying to populate a HYPERLINK section and instead and it
linking to another window, I want to use javascript to open a window
and set a window size.
THIS DOES NOT WORK. I want to write more variables that are passed
into the popup window.<%# Eval("KeywordLabel") %>

NavigateUrl="javascript:window.open('popsearch.asp?catKeywords=<%#
Eval("KeywordLabel") %>' height=200, width=400, status=yes,
toolbar=no, menubar=no, location=no'); void('');"> click
here</asp:HyperLink>

You can set the url in the code-behind:

Hyperlink1.NavigateUrl=StringFormat("javascript:window.open('popsearch.asp?catKeywords={0}',height=200,width=400,status=yes,toolbar=no,menubar=no,
location=no);", Server.UrlEncode(KeywordLabel))

(Not tested: parentheses and quotes may not be balanced.)

Andrew
 
A

Andrew Morton

Andrew said:
Hyperlink1.NavigateUrl=StringFormat("javascript:window.open('popsearch.asp?catKeywords={0}',height=200,width=400,status=yes,toolbar=no,menubar=no,
location=no);", Server.UrlEncode(KeywordLabel))

(Not tested: parentheses and quotes may not be balanced.)

And there's a dot missing from String.Format

Andrew
 
J

Joey Martin

Ok, so what I am doing wrong here:
<asp:HyperLink ID="LnkPopSearch" runat="server"
NavigateUrl='<%#
string.Format("javascript:window.open('popsearch.asp?catKeywords={0}',nu
ll, 'height=200, width=400, status=yes, toolbar=no, menubar=no,
location=no');", Eval("KeywordsList")%>'><%# Eval("KeywordLabel")
%></asp:HyperLink>
 
A

Andrew Morton

Joey said:
Ok, so what I am doing wrong here:
<asp:HyperLink ID="LnkPopSearch" runat="server"
NavigateUrl='<%#
string.Format("javascript:window.open('popsearch.asp?catKeywords={0}',nu
ll, 'height=200, width=400, status=yes, toolbar=no, menubar=no,
location=no');", Eval("KeywordsList")%>'><%# Eval("KeywordLabel")
%></asp:HyperLink>

You're using <% %> inside an <asp> tag, which may or may not work depending
on which SP of which version of the framework you're using, i.e. it is
unreliable at best. Also, that isn't the code-behind.

http://en.wikipedia.org/wiki/Code-behind#Code-behind_model

It may at first appear to be simpler to put all the logic on the aspx page
along with the markup, but you will very quickly find it easier to use the
code-behind model.

HTH

Andrew
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top