473,379 Members | 1,520 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,379 software developers and data experts.

Passing arguments to call a javascript function from aspx.cs file

Hi..

I am trying to use javascript for google maps display.
If I call the javascript function from my aspx file I use:
<input type="text" id="addresstext" value="Huntington Avenue,
Boston, MA" name="yourName" style="width: 287px" />
<input type="button" id="addressclick" value="Display Map"
onclick="showAddress(addresstext.value)" /><br />
and it works.

But using the Response.Write from the aspx.cs file it
does not display it. I need to pass an argument to the function
call.Am I passing the value wrongly??

I am calling it this way:
Response.Write("<script
language='javascript'>showAddress(getAddress);</script>");
where, getAddress is the comma-seperated Address string.

This is not displaying the map, I am creating using Javascript.

Thx

Apr 11 '07 #1
5 9816
Yes, you are passing the literal string "getAddress". I think what you want
is to pass an actual value of a string variable that represents your comma -
delimited address string, e.g.:

string getAddress = "1 Park Ave, New York, NY, 10023";
Response.Write("<script
language='javascript'>showAddress(" +getAddress+ ");</script>");

-- Peter
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short urls & more: http://ittyurl.net


"moni" wrote:
Hi..

I am trying to use javascript for google maps display.
If I call the javascript function from my aspx file I use:
<input type="text" id="addresstext" value="Huntington Avenue,
Boston, MA" name="yourName" style="width: 287px" />
<input type="button" id="addressclick" value="Display Map"
onclick="showAddress(addresstext.value)" /><br />
and it works.

But using the Response.Write from the aspx.cs file it
does not display it. I need to pass an argument to the function
call.Am I passing the value wrongly??

I am calling it this way:
Response.Write("<script
language='javascript'>showAddress(getAddress);</script>");
where, getAddress is the comma-seperated Address string.

This is not displaying the map, I am creating using Javascript.

Thx

Apr 11 '07 #2
On Apr 11, 3:38 pm, Peter Bromberg [C# MVP]
<pbromb...@yahoo.yabbadabbadoo.comwrote:
Yes, you are passing the literal string "getAddress". I think what you want
is to pass an actual value of a string variable that represents your comma -
delimited address string, e.g.:

string getAddress = "1 Park Ave, New York, NY, 10023";
Response.Write("<script
language='javascript'>showAddress(" +getAddress+ ");</script>");

-- Peter
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short urls & more: http://ittyurl.net

"moni" wrote:
Hi..
I am trying to use javascript for google maps display.
If I call the javascript function from my aspx file I use:
<input type="text" id="addresstext" value="Huntington Avenue,
Boston, MA" name="yourName" style="width: 287px" />
<input type="button" id="addressclick" value="Display Map"
onclick="showAddress(addresstext.value)" /><br />
and it works.
But using the Response.Write from the aspx.cs file it
does not display it. I need to pass an argument to the function
call.Am I passing the value wrongly??
I am calling it this way:
Response.Write("<script
language='javascript'>showAddress(getAddress);</script>");
where, getAddress is the comma-seperated Address string.
This is not displaying the map, I am creating using Javascript.
Thx- Hide quoted text -

- Show quoted text -
Thanx for the reply....but when i use this, it runs w/o displaying the
map, and gives,

Done,with errors on the page
Error: Expected ')'

But my javascript function works otherwise, and the Response.Write
line also calls it exactly this way

Response.Write("<script language='javascript'>showAddress("
+getAddress+ ");</script>");

Can you tell me wat the possible error could be.

Apr 11 '07 #3
Try putting single quotes around the parameter value, to the left and to the
right of the double quotes. Look at the string that is emitted and see if it
is legal javascript.

Peter

--
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short urls & more: http://ittyurl.net


"moni" wrote:
On Apr 11, 3:38 pm, Peter Bromberg [C# MVP]
<pbromb...@yahoo.yabbadabbadoo.comwrote:
Yes, you are passing the literal string "getAddress". I think what you want
is to pass an actual value of a string variable that represents your comma -
delimited address string, e.g.:

string getAddress = "1 Park Ave, New York, NY, 10023";
Response.Write("<script
language='javascript'>showAddress(" +getAddress+ ");</script>");

-- Peter
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short urls & more: http://ittyurl.net

"moni" wrote:
Hi..
I am trying to use javascript for google maps display.
If I call the javascript function from my aspx file I use:
<input type="text" id="addresstext" value="Huntington Avenue,
Boston, MA" name="yourName" style="width: 287px" />
<input type="button" id="addressclick" value="Display Map"
onclick="showAddress(addresstext.value)" /><br />
and it works.
But using the Response.Write from the aspx.cs file it
does not display it. I need to pass an argument to the function
call.Am I passing the value wrongly??
I am calling it this way:
Response.Write("<script
language='javascript'>showAddress(getAddress);</script>");
where, getAddress is the comma-seperated Address string.
This is not displaying the map, I am creating using Javascript.
Thx- Hide quoted text -
- Show quoted text -

Thanx for the reply....but when i use this, it runs w/o displaying the
map, and gives,

Done,with errors on the page
Error: Expected ')'

But my javascript function works otherwise, and the Response.Write
line also calls it exactly this way

Response.Write("<script language='javascript'>showAddress("
+getAddress+ ");</script>");

Can you tell me wat the possible error could be.

Apr 11 '07 #4
On Apr 11, 4:10 pm, Peter Bromberg [C# MVP]
<pbromb...@yahoo.yabbadabbadoo.comwrote:
Try putting single quotes around the parameter value, to the left and to the
right of the double quotes. Look at the string that is emitted and see if it
is legal javascript.

Peter

--
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short urls & more: http://ittyurl.net

"moni" wrote:
On Apr 11, 3:38 pm, Peter Bromberg [C# MVP]
<pbromb...@yahoo.yabbadabbadoo.comwrote:
Yes, you are passing the literal string "getAddress". I think what you want
is to pass an actual value of a string variable that represents your comma -
delimited address string, e.g.:
string getAddress = "1 Park Ave, New York, NY, 10023";
Response.Write("<script
language='javascript'>showAddress(" +getAddress+ ");</script>");
-- Peter
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short urls & more: http://ittyurl.net
"moni" wrote:
Hi..
I am trying to use javascript for google maps display.
If I call the javascript function from my aspx file I use:
<input type="text" id="addresstext" value="Huntington Avenue,
Boston, MA" name="yourName" style="width: 287px" />
<input type="button" id="addressclick" value="Display Map"
onclick="showAddress(addresstext.value)" /><br />
and it works.
But using the Response.Write from the aspx.cs file it
does not display it. I need to pass an argument to the function
call.Am I passing the value wrongly??
I am calling it this way:
Response.Write("<script
language='javascript'>showAddress(getAddress);</script>");
where, getAddress is the comma-seperated Address string.
This is not displaying the map, I am creating using Javascript.
Thx- Hide quoted text -
- Show quoted text -
Thanx for the reply....but when i use this, it runs w/o displaying the
map, and gives,
Done,with errors on the page
Error: Expected ')'
But my javascript function works otherwise, and the Response.Write
line also calls it exactly this way
Response.Write("<script language='javascript'>showAddress("
+getAddress+ ");</script>");
Can you tell me wat the possible error could be.- Hide quoted text -

- Show quoted text -
I tried doing that, it still doesnt show. Can you tell me any other
way, or the AJAx way to go about it.

Apr 11 '07 #5
On Apr 11, 4:25 pm, "moni" <mons.2...@gmail.comwrote:
On Apr 11, 4:10 pm, Peter Bromberg [C# MVP]

<pbromb...@yahoo.yabbadabbadoo.comwrote:
Try putting single quotes around the parameter value, to the left and to the
right of the double quotes. Look at the string that is emitted and see if it
is legal javascript.
Peter
--
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short urls & more: http://ittyurl.net
"moni" wrote:
On Apr 11, 3:38 pm, Peter Bromberg [C# MVP]
<pbromb...@yahoo.yabbadabbadoo.comwrote:
Yes, you are passing the literal string "getAddress". I think what you want
is to pass an actual value of a string variable that represents your comma -
delimited address string, e.g.:
string getAddress = "1 Park Ave, New York, NY, 10023";
Response.Write("<script
language='javascript'>showAddress(" +getAddress+ ");</script>");
-- Peter
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
Short urls & more: http://ittyurl.net
"moni" wrote:
Hi..
I am trying to use javascript for google maps display.
If I call the javascript function from my aspx file I use:
<input type="text" id="addresstext" value="Huntington Avenue,
Boston, MA" name="yourName" style="width: 287px" />
<input type="button" id="addressclick" value="Display Map"
onclick="showAddress(addresstext.value)" /><br />
and it works.
But using the Response.Write from the aspx.cs file it
does not display it. I need to pass an argument to the function
call.Am I passing the value wrongly??
I am calling it this way:
Response.Write("<script
language='javascript'>showAddress(getAddress);</script>");
where, getAddress is the comma-seperated Address string.
This is not displaying the map, I am creating using Javascript.
Thx- Hide quoted text -
- Show quoted text -
Thanx for the reply....but when i use this, it runs w/o displaying the
map, and gives,
Done,with errors on the page
Error: Expected ')'
But my javascript function works otherwise, and the Response.Write
line also calls it exactly this way
Response.Write("<script language='javascript'>showAddress("
+getAddress+ ");</script>");
Can you tell me wat the possible error could be.- Hide quoted text -
- Show quoted text -

I tried doing that, it still doesnt show. Can you tell me any other
way, or the AJAx way to go about it.- Hide quoted text -

- Show quoted text -
Can I use something like:

string myMap = ("<script language='javascript'>showAddress("+getAddress
+ ");</script>");
Page.RegisterClientScriptBlock(" don know",myMap);

But this is not working too...Plz help...

Apr 11 '07 #6

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

Similar topics

0
by: Prescott | last post by:
I want to execute a javascript function that will set a value in the parent window from the child widow where its called and then post the form to the server. I seem to be able to execute one or...
1
by: hrishikesh | last post by:
hi all can you tell me how to call javascript function in .aspx page i want to call it on onclick of button this codebehind code giving me some other problem like The viewstate is invalid for...
1
by: alf | last post by:
Hi, how can I pass a value from ASP.NET to a javascript function in the client-side ?? my problem is appening the ' at beginin and end of the argument: href=<%# "javascript:myFunction(" +...
2
by: hibaru | last post by:
Hi Is it possible to call a javascript function from a treeview controls OnSelectedNodeChanged event? Something similar to a OnClientClick event for buttons? I cant seem to find anyway to do...
10
by: Janus | last post by:
Hi, Is there a way to pass arguments to the callback function used inside an addEventListener? I see that I can only list the name of the callback function. For eg, I use this: var...
4
by: verci | last post by:
Hi guys, I'm running asp.net 2.0. Does anyone know how to fire or call a javascript function from inside my (VB.aspx) code without assigning it to a control attribute? thank you
1
by: santosh2003 | last post by:
Hi All, How would we call Javascript function on img click? can we call function which define in codebehind page (.vb page) on img click? Regards Santosh
1
by: DharmendraSingh | last post by:
how i call javascript function in onBlur in datagrid of Struts Layout Please anybody know reply soon Thanks & Regards Dharmendra Singh
1
KalariaNitya
by: KalariaNitya | last post by:
hello dear, i need ur help i read ur answer in http://www.dotnetspider.com/qa/Question39518.aspx regarding that i want to ask u that, if i used Text1.Attributes.Add("onblur", "return...
1
by: siddu | last post by:
How to call Javascript function in single statement, I have to call these two statements in a single onClick img.Attributes("onclick") = "toggleSidebar(" + IDPREFIXSIDEBARCONTENT + CStr(tab.Id) +...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
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: 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...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
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...

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.