473,511 Members | 15,126 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 9841
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
1819
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
1327
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
1848
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
8873
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
12980
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
59897
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
4397
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
3396
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
2725
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
1751
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
7074
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7506
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
5659
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5063
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 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 a new...
0
4734
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3219
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1572
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
780
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
445
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

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.