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

Calling c# code from javascript

Hi,
Can one call a c# function from within a javascript function ? I have a c#
function GetLanguageItem(title), how can I call the above function from a
javascript function in an .aspx page.
Thanks
Nov 17 '05 #1
4 6526
You might be able to do what you want with Web Service behaviours, but it
will be IE only

--
Regards

John Timney (Microsoft ASP.NET MVP)
----------------------------------------------
<shameless_author_plug>
Professional .NET for Java Developers with C#
ISBN:1-861007-91-4
Professional Windows Forms
ISBN: 1861005547
Professional JSP 2nd Edition
ISBN: 1861004958
Professional JSP
ISBN: 1861003625
Beginning JSP Web Development
ISBN: 1861002092
</shameless_author_plug>
----------------------------------------------

--
Regards

John Timney (Microsoft ASP.NET MVP)
----------------------------------------------
<shameless_author_plug>
Professional .NET for Java Developers with C#
ISBN:1-861007-91-4
Professional Windows Forms
ISBN: 1861005547
Professional JSP 2nd Edition
ISBN: 1861004958
Professional JSP
ISBN: 1861003625
Beginning JSP Web Development
ISBN: 1861002092
</shameless_author_plug>
----------------------------------------------

"Anita C" <an****@ptm-software.com> wrote in message
news:ul**************@TK2MSFTNGP12.phx.gbl...
Hi,
Can one call a c# function from within a javascript function ? I have a c# function GetLanguageItem(title), how can I call the above function from a
javascript function in an .aspx page.
Thanks

Nov 17 '05 #2
Yes the code is running on the client's browser.

"John Saunders" <jo***********@surfcontrol.com> wrote in message
news:OE**************@tk2msftngp13.phx.gbl...
"Anita C" <an****@ptm-software.com> wrote in message
news:ul**************@TK2MSFTNGP12.phx.gbl...
Hi,
Can one call a c# function from within a javascript function ? I have a c#
function GetLanguageItem(title), how can I call the above function from a javascript function in an .aspx page.


Is the JavaScript function running on the client's browser? If so, it

cannot directly call a function running on the server.
--
John Saunders
Internet Engineer
jo***********@surfcontrol.com

Nov 17 '05 #3
start here

http://www.webreference.com/js/column97/

read this

http://msdn.microsoft.com/library/de...thor/webservic
e/overview.asp

and see this example

http://msdn.microsoft.com/library/de...thor/webservic
e/webservice.asp

--
Regards

John Timney (Microsoft ASP.NET MVP)
----------------------------------------------
<shameless_author_plug>
Professional .NET for Java Developers with C#
ISBN:1-861007-91-4
Professional Windows Forms
ISBN: 1861005547
Professional JSP 2nd Edition
ISBN: 1861004958
Professional JSP
ISBN: 1861003625
Beginning JSP Web Development
ISBN: 1861002092
</shameless_author_plug>
----------------------------------------------

"Anita C" <an****@ptm-software.com> wrote in message
news:eM**************@TK2MSFTNGP09.phx.gbl...
Can you please point me to a sample or provide a code snippet of how to
achieve calling a c# function from javascript using WebServices ?
Thanks a lot.

"John Timney (Microsoft MVP)" <ti*****@despammed.com> wrote in message
news:uM**************@TK2MSFTNGP09.phx.gbl...
You might be able to do what you want with Web Service behaviours, but it
will be IE only

--
Regards

John Timney (Microsoft ASP.NET MVP)
----------------------------------------------
<shameless_author_plug>
Professional .NET for Java Developers with C#
ISBN:1-861007-91-4
Professional Windows Forms
ISBN: 1861005547
Professional JSP 2nd Edition
ISBN: 1861004958
Professional JSP
ISBN: 1861003625
Beginning JSP Web Development
ISBN: 1861002092
</shameless_author_plug>
----------------------------------------------

--
Regards

John Timney (Microsoft ASP.NET MVP)
----------------------------------------------
<shameless_author_plug>
Professional .NET for Java Developers with C#
ISBN:1-861007-91-4
Professional Windows Forms
ISBN: 1861005547
Professional JSP 2nd Edition
ISBN: 1861004958
Professional JSP
ISBN: 1861003625
Beginning JSP Web Development
ISBN: 1861002092
</shameless_author_plug>
----------------------------------------------

"Anita C" <an****@ptm-software.com> wrote in message
news:ul**************@TK2MSFTNGP12.phx.gbl...
Hi,
Can one call a c# function from within a javascript function ? I have
a c#
function GetLanguageItem(title), how can I call the above function
from a javascript function in an .aspx page.
Thanks



Nov 17 '05 #4
"Dejan" <de*********@expo24-7.com> wrote in message
news:uQ**************@TK2MSFTNGP09.phx.gbl...
Hi,

I solve this problem by Response.Write("<Script>");
and within this you call you java script GetLanguageItem(title)
I hope this solves your problem.
Dejan,

That doesn't work if "GetLanguageItem" is a server-side function.
--
John Saunders
Internet Engineer
jo***********@surfcontrol.com

Dejan


"Anita C" <an****@ptm-software.com> wrote in message
news:ul**************@TK2MSFTNGP12.phx.gbl...
Hi,
Can one call a c# function from within a javascript function ? I have a

c#
function GetLanguageItem(title), how can I call the above function from a javascript function in an .aspx page.
Thanks


Nov 17 '05 #5

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

Similar topics

7
by: Julia Briggs | last post by:
Hello World - I admit I'm new to javascript but I've tried for days to find a solution to my problem. Basically I have 3 unique javascript files that do different screen display events that I...
18
by: Simula | last post by:
I am developing an HTML javascript application and I want to preserve state in a way that can be book-marked. I chose HTML anchors as a means of preserving state. When the application changes...
1
by: desmcc | last post by:
Hi, I am launching a modal dialog through the usual javascript (window.showmodaldialog). When the modal dialog is complete (ie user selects OK), the calling page then refreshes itself by setting...
4
by: Martin Feuersteiner | last post by:
Dear Group I'm using VB to write an aspnet application. I would like to call a javascript function from within a VB Sub or VB Function, is it possible? My code is something like this: VB...
10
by: Tony Rice | last post by:
If I've loaded a set of functions in a webdocument like this: <script language="JavaScript" type="text/javascript" src="/js/foo.js"</script> Shouldn't I be able to call a function from...
3
by: Opa | last post by:
Hi , I have a form with javasript which launches a popup via the showModalDialog() method. I get the dialog to open, now I am trying to first get a reference to the calling form from the popup...
4
by: Adam Smith | last post by:
Hello, How can I call or trigger an external javascript twice in a form? I have <script language="JavaScript" src="country_state.js" name="Country_State"> <script type="text/javascript"...
5
by: Newbie Coder | last post by:
Hello all I have 3 functions in a javacrip file (MyScript.js), which is added to an ASP.NET 2.0 project 1) no right-click 2) no select text (copy...) 3) History.Back()' How do I call...
6
by: Ajit Goel | last post by:
Hi; We have a Javascript function which I have been tasked to move to a CSharp class. This javascript function uses Regular expression extensively. This function has a string input parameter and...
47
by: mukeshrasm | last post by:
Hi I am calling two pages using Ajax Get_Pages.php and Get_Content.php from combo box. Both pages are displayed based on selection from combo box. Main problem is that it is not showing the...
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
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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.