By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,389 Members | 2,052 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,389 IT Pros & Developers. It's quick & easy.

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

P: n/a
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
Share this Question
Share on Google+
5 Replies


P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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

P: n/a
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 discussion thread is closed

Replies have been disabled for this discussion.