469,943 Members | 2,586 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,943 developers. It's quick & easy.

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 9583
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 discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by hrishikesh | last post: by
1 post views Thread by alf | last post: by
2 posts views Thread by hibaru | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.