471,086 Members | 1,199 Online
Bytes | Software Development & Data Engineering Community
Post +

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 471,086 software developers and data experts.

Calling C#/VB.Net function in Javascript

Hi,

I have a web application where I need to call backend C#/VB.Net functions
from javascript.

Is it possible..and how?

Thanks,
Tanmaya
Jun 20 '06 #1
3 2727
when is javascript function called if it is called from aspx page itself
like we do for client side validation then it itself goes to codebehin if
true is returned
like
<asp:button id="cmdsubmit" Runat="server" Text="Submit"
OnClick="checksubmit()"></asp:button>
then on submitting javascript function will be called and if every thing
validates function associated with this submit button in code behind will be
called
function checksubmit()
{
if(document.generalinfo.elements["firstname"].value=="")
{
alert("Please enter First name ");
return false;
}
if(document.generalinfo.elements["lastname"].value=="")
{
alert("Please enter Last name ");
return false;
}

if(document.generalinfo.elements["addrline1"].value=="")
{
alert("please enter your Address");
return false;
}

if(document.generalinfo.elements["city"].value=="")
{
alert("please enter your City");
return false;
}

if(document.generalinfo.elements["state"].value=="")
{
alert("please enter your State");
return false;
}

if(document.generalinfo.elements["country"].value=="")
{
alert("please enter your Country");
return false;
}

if(document.generalinfo.elements["pin"].value=="")
{
alert("please enter your Pin");
return false;
}
if(Validatephone()==false)
return false;
}

but if ur scenario is different than i can't say

"Tanmaya Kulkarni" <ta**************@persistent.co.in> wrote in message
news:u5**************@TK2MSFTNGP03.phx.gbl...
Hi,

I have a web application where I need to call backend C#/VB.Net functions
from javascript.

Is it possible..and how?

Thanks,
Tanmaya

Jun 20 '06 #2
You can do it by using callbacks in ASP.NET 2.0
Tanmaya Kulkarni wrote:
Hi,

I have a web application where I need to call backend C#/VB.Net functions
from javascript.

Is it possible..and how?

Thanks,
Tanmaya


Jun 20 '06 #3
use __doPostBack function of javascript
Note: There Is two underscore "__"
Tanmaya Kulkarni wrote:
Hi,

I have a web application where I need to call backend C#/VB.Net functions
from javascript.

Is it possible..and how?

Thanks,
Tanmaya


Jun 20 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

10 posts views Thread by R.G. Vervoort | last post: by
4 posts views Thread by Martin Feuersteiner | last post: by
13 posts views Thread by ukrbend | last post: by

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.