codetoad.com
  ASP Shopping CartForum & BBS
  - all for $20 from CodeToad Plus!
  
  Home || ASP | ASP.Net | C++/C# | DHTML | HTML | Java | Javascript | Perl | VB | XML || CodeToad Plus! || Forums || RAM 
Search Site:
Search Forums:
  calling C# from javascript  smvcoder at 09:04 on Friday, January 27, 2012
 

Hello Everyone,

I am new to this forum.....

Just a question...

Is it possible to call code behind function from javascript?

Thanks...

  Re: calling C# from javascript  bluestar at 15:27 on Wednesday, February 22, 2012
 

yes, you can make web method like..

<WebMethod(EnableSession:=True), ScriptMethod()> _
Public Shared Function updateContent() As String
Return "Your String"
End Function

and then call in javascript like..

  Re: calling C# from javascript  Alan_Smith at 10:51 on Friday, February 24, 2012
 

It is possible to call code from C# behind function from JavaScript. First, you should create button or link so that you can easily call function by one click. After this, use code void Call_From_Server(Obj. sender, EA e). This is an easy way for JavaScript to use C# coding or function.

  Re: calling C# from javascript  paddysmith at 07:27 on Saturday, March 03, 2012
 

For .Net you could also wrap your page in a panel, and use the "DefaultButton" property to pick the linkbutton.

<asp:Panel DefaultButton="btnSearchNow" runat="server"> ... </asp:Panel>


  Re: calling C# from javascript  sathish_chennai at 12:33 on Friday, July 20, 2012
 



Here is a sample using asp.net - Ajax, Two steps

a. Design / Script code

<asp:ScriptManager ID="ScriptManager1" runat="server"
EnablePageMethods="true" />
<script language="javascript">
function UpdateTime() {
PageMethods.GetCurrentDate(OnSucceeded, OnFailed);
}

function OnSucceeded(result, userContext, methodName) {
$get('Label1').innerHTML = result;
}

function OnFailed(error, userContext, methodName) {
$get('Label1').innerHTML = "An error occured.";
}
</script>
<asp:Label runat="server" ID="Label1" Text="Update Me!" /><br />
<input type="button" id="Button2" value="Web Method Update"
onclick="UpdateTime();" />

b. C#


[WebMethod]
public static string GetCurrentDate()
{
return DateTime.Now.ToLongDateString();
}



  Re: calling C# from javascript  suprasneaker at 04:59 on Thursday, September 13, 2012
 

<p><a href="http://www.supratksocietyshoesoutlet.com/">Online Supra Sneaker Outlet</a>, Factory Direct!You will find that low price and top quality <a href="http://www.supratksocietyshoesoutlet.com/">Supra Footwear cheap sale</a> for people to choose from. Get best service by every purchase of Supra Footwear. <a href="http://www.supratksocietyshoesoutlet.com/">www.supratksocietyshoesoutlet.com</a> has the latest information about <a href="http://www.supratksocietyshoesoutlet.com/">Justin Bieber Shoes</a>. More information about <a href="http://www.supratksocietyshoesoutlet.com/">Justin Bieber Supra Shoes</a> including release dates and prices. Thanks for your attention on our store.
Find your favorite styles from our large collection of <a href="http://www.supratksocietyshoesoutlet.com/">Supra Footwear</a>,<a href="http://www.supratksocietyshoesoutlet.com">Supra Shoes UK</a> and more!Top quality <a href="http://www.supratksocietyshoesoutlet.com/">Supra Society Mid Shoes</a> are hot sale now,welcome to our <a href="http://www.supratksocietyshoesoutlet.com/">Supra Shoes Store</a> the more surprise waitting for your such as high quality,fast shipping and 46% OFF!
<p>This <a href="http://www.supratksocietyshoesoutlet.com/men-supra-society-mid-shoes-c-15/">Men Supra Society Mid Shoes</a> is the most fashion style this season.The <a href="http://www.supratksocietyshoesoutlet.com/">supra store</a> is a good choose,and became a bright point for this Supra Shoe.<a href="http://www.supratksocietyshoesoutlet.com/men-supra-skytop-shoes-c-4/">Men Supra Skytop Shoes Discount</a>,We stock various <a href="http://www.supratksocietyshoesoutlet.com/">Cheap Supra Skyop Shoes</a> with top quality and cheapest price.Your complete satisfaction is our top priority for long term business between us.Our shop is your best choice to buy <a href="http://www.supratksocietyshoesoutlet.com/">Supra Skytop</a>.All shoes are packaged with original tags,fast mailing to your door.Welcome to choose one!</p>
<p>Best <a href="http://www.supratksocietyshoesoutlet.com/">Supra shoes online</a> retailer here!Many fashion justin bieber shoes just design for you.High quality <a href="http://www.supratksocietyshoesoutlet.com/kid-supra-skytop-shoes-c-11/">discount Kid Supra Skytop Shoes Sale Online</a> at low prices.</p>
<p><a href="http://www.supratksocietyshoesoutlet.com/2012-new-supra-tk-society-c-2/">2012 New Supra TK Society</a>
<a href="http://www.supratksocietyshoesoutlet.com/justin-bieber-shoes-c-1/">Justin Bieber Shoes</a>
<a href="http://www.supratksocietyshoesoutlet.com/men-supra-skytop-shoes-c-4/">Men Supra Skytop Shoes</a>
<a href="http://www.supratksocietyshoesoutlet.com/men-supra-skytop-iii-shoes-c-7/">Men Supra Skytop III Shoes</a>
<a href="http://www.supratksocietyshoesoutlet.com/men-supra-tk-society-shoes-c-3/">Men Supra TK Society Shoes</a>
<a href="http://www.supratksocietyshoesoutlet.com/men-supra-vaider-shoes-c-9/">Men Supra Vaider Shoes</a>
<a href="http://www.supratksocietyshoesoutlet.com/women-supra-skytop-shoes-c-6/">Women Supra Skytop Shoes</a>
<a href="http://www.supratksocietyshoesoutlet.com/women-supra-skytop-iii-shoes-c-8/">Women Supra Skytop III Shoes</a>
<a href="http://www.supratksocietyshoesoutlet.com/women-supra-tk-society-shoes-c-5/">Women Supra TK Society Shoes</a>
<a href="http://www.supratksocietyshoesoutlet.com/women-supra-vaider-shoes-c-10/">Women Supra Vaider Shoes</a>
<a href="http://www.supratksocietyshoesoutlet.com/kid-supra-skytop-shoes-c-11/">Kid Supra Skytop Shoes</a>
<a href="http://www.supratksocietyshoesoutlet.com/kid-supra-tk-society-c-12/">Kid Supra TK Society</a>
<a href="http://www.supratksocietyshoesoutlet.com/supra-pilot-shoes-c-13/">Supra Pilot Shoes</a>
<a href="http://www.supratksocietyshoesoutlet.com/supra-cuttler-ns-shoes-c-14/"></a>
<a href="http://www.supratksocietyshoesoutlet.com/men-supra-society-mid-shoes-c-15/">Men Supra Society Mid Shoes</a>
<a href="http://www.supratksocietyshoesoutlet.com/women-supra-society-mid-shoes-c-16/">Women Supra Society Mid Shoes</a>
<p><a href="http://www.supratksocietyshoesoutlet.com/2012-supra-skytop-black-grey-orange-shoes-p391.html">2012 Supra Skytop Black Grey Orange Shoes</a> <a href="http://www.supratksocietyshoesoutlet.com/2012-supra-skytop-black-grey-purple-shoes-p392.html">2012 Supra Skytop Black Grey Purple Shoes</a> <a href="http://www.supratksocietyshoesoutlet.com/2012-supra-skytop-black-red-sneaker-p393.html">2012 Supra Skytop Black Red Sneaker</a> <a href="http://www.supratksocietyshoesoutlet.com/2012-supra-skytop-black-white-green-black-p394.html">2012 Supra Skytop Black White Green Black</a> <a href="http://www.supratksocietyshoesoutlet.com/2012-supra-skytop-black-white-snowflake-shoes-p395.html">2012 Supra Skytop Black White Snowflake Shoes</a> <a href="http://www.supratksocietyshoesoutlet.com/2012-supra-skytop-blue-snowflake-shoes-p396.html">2012 Supra Skytop Blue Snowflake Shoes</a> <a href="http://www.supratksocietyshoesoutlet.com/2012-supra-skytop-grey-black-snowflake-shoes-p397.html">2012 Supra Skytop Grey Black Snowflake Shoes</a> <a href="http://www.supratksocietyshoesoutlet.com/2012-supra-skytop-grey-snowflake-shoes-p398.html">2012 Supra Skytop Grey Snowflake Shoes</a> <a href="http://www.supratksocietyshoesoutlet.com/2012-supra-skytop-white-black-snowflake-shoes-p399.html">2012 Supra Skytop White Black Snowflake Shoes</a> <a href="http://www.supratksocietyshoesoutlet.com/2012-supra-skytop-white-orange-snowflake-shoes-p400.html">2012 Supra Skytop White Orange Snowflake Shoes</a>








CodeToad Experts

Can't find the answer?
Our Site experts are answering questions for free in the CodeToad forums








Recent Forum Threads
• Run a program both on windows and linux
• VERO.SurfCAM.v2014
• Schlumberger.Petrel.V2013.2
• Petrel.V2013.2
• Altair.HyperWorks.v12
• VoluMill.v6.1
• VoluMill.NEXION.6
• VERO.SurfCAM.v2014
• Schlumberger.Petrel.V2013.2


Recent Articles
ASP GetTempName
Decode and Encode UTF-8
ASP GetFile
ASP FolderExists
ASP FileExists
ASP OpenTextFile
ASP FilesystemObject
ASP CreateFolder
ASP CreateTextFile
Javascript Get Selected Text


© Copyright codetoad.com 2001-2014