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

How to call a button_click(aspx.cs) event from javascript function

1
How to call a button_ click event from javascript function
i need syntax for call a button click event from javascript.
Jun 30 '07 #1
1 6446
kenobewan
4,871 Expert 4TB
Not directly, no. Server-side functions live server-side, client-side functions live on the client.

One way to get 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.

Another way - instead of hardcoding the postback method name in your page script, I'd recommend you use the GetPostBackEventReference() method off the Page class. This will return you the generated method name and will most likely be forward compatible. It also handles the issue of ensuring that the client-side method is emitted to the page markup.

Page.GetPostBackEventReference Method

ASP.NET 2.0 has a feature call "client call-backs" which perform exactly what you are looking for. They can be activated within the 2.0 GridView control (similar to DataGrid) so that the body of the grid is redrawn without the need for a full page postback. HTH.
Jul 1 '07 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

3
by: Tim Thomas | last post by:
Hi, I am very new to .NET and am in the process of building my first web application. I will briefly describe what i am trying to achieve: I have a system where suppliers register their...
7
by: Tim T | last post by:
Hi, I have the need to use dynamically loaded user controls in a webform page. I have the controls loading dynamically, and that part works fine. this is the code used in a webform to dynamically...
5
by: Jade | last post by:
I saw some web page saying I could do it this way in javascript: var iNumber = <%#publicvarname publicpropertyname %> but it doesn't seem to work. I have this piece of code here in...
4
by: Vinod | last post by:
Hi Team, Can we call ".aspx" files from ".asp" ? How ? Thanks in advance
2
by: Skating_vince | last post by:
I have a problem, i have a form with some input boxes and a submit button. In the Submit_Click event, the data from the input boxes is stored in a database. But, if you click the button, ASP.NET...
2
by: Frank Schumacher | last post by:
Hi Folks, I have a problem with the order of events fired by ASP.NET. I found many articles which explaining the lifecycle of a site, but I found none which took the event from a Control on the...
1
by: santosh2003 | last post by:
Hi All, How would we call Javascript function on img click? can we call function which define in codebehind page (.vb page) on img click? Regards Santosh
3
by: Jimmy | last post by:
It is also possible for popup window to call function in main window by using the opener property. Will "opener.someFunctionInMain(param1, param2)" in the popup window work? It's possible for...
2
by: wolverine2512 | last post by:
Hello .Net Wizards! I would like to seek your help on how to call javascript function from code behind of VB.net. I have javascript function named Openform() and i want to execute it on page load,...
0
by: Michal Kwiatkowski | last post by:
I'm building a tool to trace all function calls using sys.settrace function from the standard library. One of the awkward behaviors of this facility is that the class definitions are reported as...
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: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...

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.