calling server side function from client side script

i have a web form that includes a function named  "koko()"  in its server side class

i want to write a script code in in its HTML script that will be run at the client side, and this client side script will call the function "koko()" from the server side.
in brief : i want to call a server side function from a client side script...
can you help me in this
0
khaled_zs
3/9/2005 11:56:59 AM
asp.net.client-side 24353 articles. 2 followers. Follow

7 Replies
1741 Views

Similar Articles

[PageSpeed] 11
Get it on Google Play
Get it on Apple App Store

You can't call server-side code directly from client-side code.  You can, however, trigger a postback that your server-side code watches for and triggers the server-side code appropriately.

You can do some browser-specific things that do a partial postback, but I try to avoid being too browser specific.
0
stiletto
3/9/2005 12:41:33 PM
you could look at invoking an aspx with a certain querystring param and look in the pageload event to see if that param is present then run your function...do this by using a behind-the-scenes xmlhttppost call. You can make this cross browser

e.g in javascript run this method
var pageUrl = 'ClearSession.aspx';
var xmlRequest = new ActiveXObject("Microsoft.XMLHTTP");
xmlRequest.open("POST", pageUrl, false);
xmlRequest.setRequestHeader("Content-Type", "application/x-www-form-urlencoded");
xmlRequest.send(null)
or just make a client side call to a webservice
for the clientside web service call check out
http://msdn.microsoft.com/library/default.asp?url=/workshop/author/webservice/overview.asp
0
asyahub
3/9/2005 12:47:14 PM
thank you for your reply

would you please send me an example for the solution you gave me that is;
"Trigger a postback that your server-side code watches for and triggers the server-side code appropriately "
0
khaled_zs
3/9/2005 12:55:42 PM
Here are some ideas:

Create a button (could be invisible), and then trigger that button. Within the button's onClick event, you call the koko() function. You can easily trigger the button as if it was clicked by the user by using the following javascript code (assuming the button's id as Button1):
__doPostBack("Button1","");
If you want to call the function without a postback, you cannot. But you can make it look like the postback never happened. To do this, you can put a very very small frame on the bottom of the page and put the button in it. You could easily simulate the button click from the main frame using the javascript above.
This way, the user thinks that no postback has occured, when what has actually happeded is that the postback has occured, but the user could not see it as it happpened in a frame the user cannot see.
Hope that hasnt confused you.
Intelligence is a burden.
Jagdip Singh Ajimal
Manchester (and yes, I am a Manchester United fan)
0
jagdipa
3/9/2005 1:55:02 PM

I have gridview and  i displaying  data from  database that is on Enterprise server

when i click a particular item in gridview i  am opening a client application. for this all stuff i written the server side code in my local system.

(in gridview_selectedindexed change event)// i writen the code

if i have open my application (after installed in IIS ) from other machine or  from client system, i can't able to open my  client application

here i need to tell the browser to  open the application  but how i over come this. to write clienside script.  to execute server side code. (in other system)

 

 


adilahmed
0
adilahmedmd
11/15/2008 3:02:42 PM

adilahmedmd@gmail.com please don't double post especially into other people's threads. You now have 3 posts, counting this one, on the same question.

http://forums.asp.net/t/1348604.aspx
http://forums.asp.net/t/1348714.aspx

Also I posted a solution for this issue at one of your other threads: http://forums.asp.net/t/1348714.aspx

NC...

0
NC01
11/16/2008 2:31:59 PM
HI,

//javascript

function servercall()
{
 document.getElementById(").click();
}

//Codebehind
protected void button1_click(object sender, Eventargs e)
{
try
{
  kokc()//your function, whatever it is,
}
catch(Exception ex)
{
}
}

please check the casesenctive.
hope it will work.
Thanks & Regards
JNS

Remember to click on Mark as answer on the post that helped you
0
jnagasuresh
11/16/2008 2:55:45 PM
Reply:

Similar Artilces:

Client side script calling Server side functions
Hi, I'm currently developing an ajax.net enabled aspx page that contains a usercontrol (which is based on the listbox but extends it to include icons to represent invalid data). http://www.djcharlie.co.uk/WeeeCareResolutionCentre.jpg I want the onClick event of the selected TR to call an asp.net server function which then populates the controls to the right hand side in the page. Obviously because the row is just rendered HTML overriden from the base class I can only assign a javascript function to the onClick event. So I need a way of calling a server side function that will populate that will populate the right hand controls from an object based on the row's ID. I tried playing around with EnablePageMethods after some google-hunting but a) I don't have have that attribute on my scriptmanager (and I have reinstalled the extensions again) and b) apparently it can only call static methods and of course static methods cannot populate controls at page level.  Thanks in advance, DJCharlie Just to put this in English, you need to get the address data from the database pertaining to the Company that is selected on the left, and update the values in the textboxes on the left with it, without effecting a full postback?  Is that right?If so, have a look at the xmlhttprequest object in javascript.  This is one of the most straightforward explanations of how to use it, and while the example is classic ASP, you should get the jist. Regards Mike [MVP - ASP/A...

Call server-side script from client-side script
Hi to all, I would like to ask you How can i call from client-side script a server-side script and to have the result from the server-side script in the client-side script. For example, i wand to call a function writing in server-side (DynaScript) script from a client-side script (JAVASCRIPT) and to have an answer from the function. Thanks in advance. Nick, One way that you could get round this is to write your client script code as you would server script eg. <SCRIPT language=javascript> function getValue()... would be written as: <% psDocument.WriteLn("<SCRIPT language=javascript>"); psDocument.WriteLn("function getValue()"); %> This way your client value is essentially your server side value(and vice versa) and can be accessed easily. Davlon nick wrote: > Hi to all, > I would like to ask you How can i call from client-side script a > server-side script and to have the result from the server-side script > in the client-side script. For example, i wand to call a function > writing in server-side (DynaScript) script from a client-side script > (JAVASCRIPT) and to have an answer from the function. > Thanks in advance. From client script you need to link to a page in order to fire off a server script. You can link to the current page and pass parameters to indicate it's a reload or whatever and process based on that. A server-side script can create HTML ...

How to call a client side script from a server side script?
Hi guys, I have a Button1_Click function which gets executed on the server side as soon as Button1 is clicked. I have a client side function, test, which is  written in vbscript. I need to call this test function from the Button1_Click function. Can anyone of you please tell me how to do this? The test function is inside an asp:content tag (Please excuse my terminology if I am wrong, I am new to all this).  Thanks and Regards, RJ Have you tried to use the below code Button1.Attributes.Add("onclick","test()"); HCHaissam Abdul MalakMCAD.NET| Blog | Yes, ...

Is it possible to call client side function from server side code without initial client request?
Atlas is great. I'm using timer to periodically check database changes on server to populate client side controls with new data. Is it possible to do it without a lot of client requests to server which takes a huge useless network traffic? Server should call client side function on all connected clients when, for example, 'database updated' event occurs on server. Thanks. Hi~ Just for your interest, I think you could have a look at Comet, many web IM like Gmail's embeded Gtalk and meebo.com are built on this architecture你好! Just FYI o_O...

How do I call server side function in client side script without using __doPostBack
Hello, My page has a server side panel that is hidden when the page loaded, checkboxes inside of the datagrid, and buttons.  If at least one checkbox is not clicked and the user click on the button, I show the panel.  When the user click on one of the checkbox, I want to hide the panel.  Onclick on the checkbox I already have a cleint function to change the row color.  I don't want to use __doPostBack.  Don't want to do postback. My question are: How do I either have checkbox onclick called both client and server side functions.  Or have the client side function call the server side function to hide the panel. Thank you Hi Kathy - If you have a Panel with the ID of pnlError, and a CheckBox with the id of chkRow, you could use the following logic (in the Page Load event) I'm assuming VB, let me know if you need C#     Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load        chkRow.Attributes.Add("onClick", "document.getElementById('" & pnlError.ClientID & "').style.display='none';")     End Sub To show the panel, use style.display=''; Tyler, Thank you for the tip.  It works, but.. I already have the onClick atttributes added for client side for something else.  Can I have the OnClick doing more than one? ' add on click to each checkbox' chkSelect.Attributes.Add("OnClick", "javascript:c...

Calling a client side function from the server side
Is it possible to call a client side function from the server side. I dont want to invoke that function through button click. I just want to call that to do some operations.  Regards, Aish Use the below code ASP.NET 2.0 Page.ClientScript.RegisterStartUpScript(this.GetType(),"callfunction","<script language=javascript>Test();</script>"); ASP.NET 1.X Page.RegisterStartUpScript("callfunction","<script language=javascript>Test();</script>"); Where Test() is the javascript function. HCHaissam Abdul MalakMCAD.NET| Blog | No, it is not possible.  The cl...

How to call server side function on client side
Hi,   How to call server side function on client side? here i want to call change() function on textbox onchange event.   <script language="javascript">    function serverfunction()    {    }    </script><input id="Text1" onchange="javascript:serverfunction();"  type="text" /> code behind:  public void change()    {        Response.Write("hello");    } <script type=&quo...

Calling server side scripts from client side
Hello, Can Anyone help out from the following : It is regarding calling server side scripts from client side events. I am able to instantiate a jaguar component in the server side script written in the body of the HTML page as follows : <% var mycomp = java.CreateComponent ("pkg_dispatch/n_jaguar", "iiop://jaguar:9000", "Jagadmin", "" ); if (mycomp == null) { document.writeln("ERROR: failed to instantiate !"); return; } %> I want to use the instance of the jaguar component else wher...

How to call server side(C#) function from Client side(Javascript) function?
Hi i have used below functions,  function HandleOnClose() {// this function will be called after clicking browsers close button in Internet explorer if (event.clientY < 0) { event.returnValue = 'Are you sure you want to leave the page?'; } // if he clicks ok then i need to call one server side function in this instance.. else not. } <body onbeforeunload="HandleOnClose()" leftmargin="0" rightmargin="0">other controls in page..</div>  How to achieve this? Thanks MS AJAX Extensions would be the option of choice here. Combined with webservices you can...

client-side scripting or server-side scripting
I want to perform data validation in my page using javascript before the data is sent to my server, but I am very confuse that I don't know which way to perform, client-side validation or server-side validation? My javascript bible told me that javascript is a client-side scripting for data validation in client pc, but when I look in my asp.net bible, the validation part is done at server side. The worst is that, I find no way to use javascript in .asp or .aspx environment. I am really confuse with all these, could any one help me on this? Thanks. Use .NET validator co...

How to Call server side and client side function on same LinkButton
hello,         i have one linkbutton when i click on linkbutton i insert record in DB using onclick=Linkbutton_click. if successfully insert then returnvalue is 1. after return 1 i want to call javascript function. how i can do this? Reply ASAP. Is It Possible? e.g. <asp:LinkButton ID="Operation_Link" runat="server" OnClick="Operation_Link_Click"></asp:LinkButton>protected void Operation_Link_Click(object sender, EventArgs e) {if (Operation_Link.Text == "SUBMIT") {ReturnValue = company.InsertCompany...

Call client side function from server side code
My problem is that in some point of the VB.Net code I need to call a function defined in vbScript, for example: Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click   'There's some code here....   ' ...   If (SomeCondition) Then   'HERE'S WHERE I NEED TO CALL THE JAVASCRIPT FUNCTION... SO HOW CAN I DO THAT?   Else     '...   End If   ' ... End Sub The asp.net code runs to generate the html and when it is done the html is rendered in your browser. So you can't access cli...

How to call server side function from client side JavaScript?
I want to call a server-side function, like a button's click event or just another private or public function , from a client-side JavaScript function. How do I do that? thanX AnzIf this post was useful to you, please mark it as answer.ClientSideAsp.Net | Blog Maybe alittle more that you need, but....... 1) Put a button on the page. Lets say its id is Button1. Make sure that its has causesValidation=false 2) Write the code for the button. 3) Write the following in the PAge_Load event Button1.Attributes.Add("onClick", "myJSFunction(); return false") 4) Copy this javascript onto your page. function myJSFunction() {         //Fix to get the button to validate the page         if (typeof(Page_ClientValidate) == 'function')         {                 Page_ClientValidate();         }         if (Page_IsValid)         {                 var answer = confirm('Do you wish to continue?');                  if (answer)                 {                     &...

how to call server side function from client side javascript?
Hi all, I have a image button in the update panel. I would like to call a method from server side (not from webservice) to get the variable when Onclick on the image button is invoked. Is there any way that I can able to access this function from the client script? In using the UpdatePanel, in essence, you're already doing this because there will not be a full postback.  You can make an asynchronous call to your Click method of your ImageButton.  So, what do you want to do with this "variable"?Christopher Reed"The oxen are slow, but the earth is patient."...

Calling a server-side procedure from a client-side function
I have a server side function that executes a database stored procedure, and I need to be able to call it from a javascript function.  Is this possible (without using an iFrame)?  Post back the page or use Ajax. Eric Pascarello.com | Twitter epascarello | LinkedIn...

Calling server side function from client side alert
Hi, I am developing an ASP.Net application in which I am giving client side alert to the user with OK and Cancel buttons. Can I call a server side function from the click of this button? For e.g. I have to give user alert "Do you want to save record" with Yes/No button. On Yes button click it should go to the server and save the record. Can I call some server side function from the Yes button click? Any help in this regard will be highly appreciated. Thanks in advance. Ashish I would create a button control, say Button1. set Button1.visible=False then, ...

Call server side function from client side javascript
I have a javascript where I either need to call an onclick even of a server link button or I need to be able to call a server side function.   The only thing is I cant use AJAX.  Is there any way I can do this or am I spinning my wheels. Thanks!-------------Please: Don't forget to click "Mark as Answer" on the post that helped you. That way future readers will know which post solved your issue. I have a similar problem.  In my case, I would like to set a server-side session object from JavaScript.  Any suggestions?  Thanks.  Dan Sure, y...

Calling a client side control event from a server side function
I would like to know how to raise an event on a client side only control from a server side function.   For example, I have Button1 whose onclick is handled at the server. The logic behind the function will do 1 of 2 things, change the text of a label to indicate a problem or navigate to a new page.  I cannot use redirect because i need the new page to appear inside 2 of 3 existing frames.  I can manage this using an anchor on the client.  All I need to do is automatically click the anchor after I post back from the Button1.click event.I tried the following line of c...

Calling a server side function from client side using the toolkit
Ok, I'm sure this is a really stupid question, but I'm willing to ask it anyway.  Let's say that I created a new extender called "My", so I now have three files files, MyExtender.cs, MyBehaviour.js, and MyDesigner.cs.  I want my control to be able to take some data on the client side and use it to retrieve some data on the server side, which AJAX is all about right? :) So for the sake of argument, let's say I want to enter an email address in a textbox, and then consult a database to return the user's password. So in my MyExtender.cs file, I create a function something like this: public string getPassword(string email) { ... Make some database calls to get the info return password;  } What code do I put into the MyBehaviour.js file in to to call the getPassword function? And do I need any special decorations on the getPassword() function to make it happen?-Todd Davishttp://www.SeaburyDesign.com You can use ICallbackEventHandler interface for this purpose. This is the exact purpose of this interface in ASP.Net 2.0. Check out the MSDN for this interface.- SujitDont forget to click "Mark as Answer" on the post that helped you.This credits that member, earns you a point and marks your thread as Resolved so we will all know you have been helped. You really should look at how to create an extender to do it the best way.  There is a great tutorial here, http://www.asp.net/ajax/ajaxcontroltoolkit/samples/...

client side script Vs Server side Script
Which is better ? Using Client Side validations with Java Script or Using Server Side validation controls provided in asp.net You should use both... Client-side for a rich user experience and server-side to support browsers without javascript support or with javascript turned off....

Client-Side scripting vs Server-Side scripting
hello I need an article that spaeks about Client-Side scripting vs Server-Side scripting,and when i need to use one of them thank you for the help and for the time here are some good links to a bunch of articles on that subject...

Difference between client side scripting and server side scripting
Hi,      Can u  plz, explain why the server side scripting is necessary, inorder to write the client side scripting. What is the main difference between the client side scripting and server side scripting. Client-side scripting is code that is executed on the client side, such as JavaScript. Server-side scripting is code that is executed on the server, such as VB, VB.NET, C#, or J#. For a better definition of server-side scripting and when it's necessary, please visit http://en.wikipedia.org/wiki/Server-side_scriptingRyan OlshanASPInsider | Microsoft MVP...

Client-Side and Server Side Scripting
Hi, im currenty in the process of trying to get an asp.net page to work with both <script> and <script runat="server" tags... idea being, i have a <script> tag which holds all the client side scripting for my webpage, at the moment this is just some slider controls which i have created (the scripting behind this is actually from someone on a different forum, which i have modified to do what i want..) - but i also want a <script runat="server"> tag to hold all the code for the buttons pressed etc in my web-page. im trying my hardest not to use a ...

Call server-side page function from client-side button click
I have an existing ASP application that I am migrating to ASP.net. In the ASP app I was using the Microsoft.XMLHTTP on a the client-side of a ASP page to retrieve data from another asp page using the Microsoft.XMLDOM object. The client page passes 3 tags columns, table and Criteria. The receiving page builds the SQL statement executes the query and returns the row with all the column data. I am trying to convert it over to ASP.NET and I am getting errors on the xmlDOM.Load(Request.InputStream) on DLookup.aspx, the code is listed below. Someone suggested to use System.Net HTTP classes su...

Web resources about - calling server side function from client side script - asp.net.client-side

Wave function - Wikipedia, the free encyclopedia
... (a ball attached to a spring ) in classical mechanics (A-B) and quantum mechanics (C-H). In quantum mechanics (C-H), the ball has a wave function ...

Eating chocolate 'improves brain function' - study
... news for those with a sweet tooth - a recent study has found that regular chocolate consumption is associated with better cognitive function. ...

Resource sector may outsource finance functions to Asia
Outsourcing financial functions to Asia is one tactic struggling Australian energy and resources companies may use this year to survive the slump ...

Using Functions to Make Better Abstractions
... (code that is tightly coupled to its own implementation details). I was wrong. I was wrong because I had an incomplete understanding of functions. ...

Cisco launches new network functions virtualization infrastructure solution to help service providers ...
Al-Bawaba Cisco launches new network functions virtualization infrastructure solution to help service providers run network ... Al-Bawaba ...

A Non-Sokratic Dialogue on Social Welfare Functions: Hoisted from the Archives from 2003
**[A Non-Sokratic Dialogue on Social Welfare Functions: Hoisted from the Archives from 2003](http://www.j-bradford-delong.net/movable_type/2 ...

Yahoo Begins Grim Job of Closing Functions, Laying Off Staff
Yahoo Food is closing, and other digital magazines on tech, travel and beauty are also scheduled for closing or major cutbacks.

Don’t tase me, bro: Study shows being shocked by a Taser disrupts brain function
Researchers at Drexel shot a bunch of college students with 50,000 volts. The result? Short-term declines in cognitive function comparable with ...

Engineers 3D Print Tissue That Mimics How The Human Liver Functions
Engineers say they have 3D printed life-like liver tissue that could be a new platform in the lab to test the efficacy of drugs saving pharmaceutical ...

A 3D Printed Jet Engine Appears to Function
... jet engine . You may remember seeing a 3D printed jet engine grace our front page back in October. That one was beautiful didn’t function . ...

Resources last updated: 2/26/2016 9:52:21 AM