Hi Guys,

Is it possible to call the C# function from Javasript......

Sushil Kumar :rolleyes:

Not directly, no. Server-side functions live server-side, client-side functions live on the client.

In fact, the only way to get ANY server-side code to run, is to submit the form. ASP.NET unrolls the HTTP headers, unpackages the hidden ViewState variable, re-instantiates objects, and then decides what events to raise based on all of the above.

What you can do is have your JavaScript function set a hidden form variable, then do a form.submit().

Then, in your Page_Load handler on the server, use the Request object to check for the presence and/or value of this variable, and call the appropriate server-side method.

Hi Guys,

Is it possible to call the C# function from Javasript......

Sushil Kumar :rolleyes:

Yes it is possible to call C# function through javascript using Ajax extensions in Asp.Net

Just a quick thought here. Vfp programmer learning C#, .net, etc. Even with the time differences on the post I found it really helpfull on my learning curve. Thanks guys!!!
Oct 27, 3009!

Just a quick thought here. Vfp programmer learning C#, .net, etc. Even with the time differences on the post I found it really helpfull on my learning curve. Thanks guys!!!
Oct 27, 3009!

Attention Dani ! We have got an alien from future in this board.

my ID :yasu_6in@yahoo.co.in

without using javascript how to call a server side in function in textbox onblur event

ex:

public void disp()
{
Response.Write("Hi");
}

page_Load()
{
TextBox1.Attributes.Add("onblur","disp()");
}

its not working

how to call this function

without using javascript or any other scripts

similarly i need concept from textbox blur event , not any button events

plz help me to get a code ..

Thanking You

You should use web service or wcf (axaj)
send method to web service than shuld run to "this.GetType().InvokeMember" for the method

i am using , very good tecnology same windows application,

There is a way to do that. In your page add a button and then call button click via javascript. The event on button click will call a C# method after OnClick is called.

There is a sample for you:

<script language="javascript" type="text/javascript">

function ParentWindowFunction()

{
    document.getElementById('<%=cmdUpdateField.ClientID%>').click();
}

</script>


//---------------
<asp:LinkButton CssClass="dnnPrimaryAction"
ID="cmdUpdateField" runat="server" Text="Update Fields" 
onclick="cmdUpdateField_Click" ></asp:LinkButton>


//--------------In your code behind page
protected void cmdUpdateField_Click(object sender, EventArgs e)
{
    DoSomething();
}

As you can see. When you call javascript name ParentWindowFunction it will active the method at code behind. This is how javascript communicate with C#
This article has been dead for over six months. Start a new discussion instead.