I want to call a server-side function, like a button's click event, from a
client-side JavaScript function. How do I do that? Thanks. 3 15504
In order to call server-side code you have to post back to the web server.
If you examine the HTML that is generated on a simple web page with a
button, you will get a pretty good idea how to do that. It's just calling a
javascript that ASP.NET automatically generates in your web page.
"lanem" <la***@discussi ons.microsoft.c om> wrote I want to call a server-side function, like a button's click event, from a client-side JavaScript function. How do I do that? Thanks.
Do you mean you want to fire a server-side event?
Eliyahu
"lanem" <la***@discussi ons.microsoft.c om> wrote in message
news:A2******** *************** ***********@mic rosoft.com... I want to call a server-side function, like a button's click event, from a client-side JavaScript function. How do I do that? Thanks.
Lanem:
Your question is a little vague..if you just want to dynamically trigger a
postback, you can use the __doPostback function:
<asp:button id="x" runat="server" />
<a href="javascrip t:__doPostBack( 'x', '');">hahah I'm sooo clever!</a>
If you only have Buttons and no LinkButtons or other controls which require
__doPostBack, you'll have to trick the page into generating the Javascript
for you (button's don't need javascript)...y ou can use
Page.GetPostBac kClientEvent(x, ""); where x is the id of the button
control.
the above <a tag will cause x's click event to fire in codebehind.
If you want to fire server-side code without generating a postback, you'll
need to look at XmlHTTP, here's a good link dump: http://www.quirksmode.org/blog/archi...p_linkdum.html
Karl
--
MY ASP.Net tutorials http://www.openmymind.net/ - New and Improved (yes, the popup is
annoying) http://www.openmymind.net/faq.aspx - unofficial newsgroup FAQ (more to
come!)
"lanem" <la***@discussi ons.microsoft.c om> wrote in message
news:A2******** *************** ***********@mic rosoft.com... I want to call a server-side function, like a button's click event, from a client-side JavaScript function. How do I do that? Thanks. This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics |
by: HarveyB |
last post by:
I would like to generate non-modal popup windows from
ASP.Net code-behind. I have tried using Client Side
scripting like "function Test(){
window.open('test.htm',_blank,
'height=200,width=400,status=no,toolbar=no,
menubar=no,location=no resizable=no
scrollable=no');
but I can't seem to invoke the client side script from
within a Server Side Form. I know I can use the context
with to Response.redirect or Server.transfer to return a
|
by: cheezebeetle |
last post by:
ok, so I am having problems passing in an ASPX function into the Javascript in the codebehind page. I am simply using a confirm call which when they press "OK" they call this ASPX function, when they press "Cancel" they call another ASPX function.
My code now is:
System.Web.HttpContext.Current.Response.Write("<SCRIPT LANGUAGE=""JavaScript"">" & vbCrLf)
System.Web.HttpContext.Current.Response.Write("if (confirm('Are you sure you want to...
|
by: Mike Moore |
last post by:
Can an asp.net button that is a server side control call a client side java
function when the button is clicked? If so, please provide
example.....thanks.,
|
by: David Shorthouse |
last post by:
Hey folks,
Not an off-topic posting.....since I was shot-down in an earlier
post...this one's legit.
How do I go about calling a server-side vbscript within a client-side
javascript function? What I have is a page heavy on the javascript that has
a number of functions, one of which is to begin a visual countdown with an
onclick and also open an asp page containing the server-side vbscript, which
initiates a wake-on-lan call. I had no...
|
by: Randell D. |
last post by:
Folks,
I'm sure this can be done legally, and not thru tricks of the trade - I
hope someone can help.
I'm writing a 'tool' (a function) which can be used generically in any
of my projects. When it completes, it can call a success, or a failure
function. The names of these success, or failure functions will differ,
and I'd like to know how I can pass the name of a function to my tool,
and how my tool can call the function, using that...
| |
by: prince -=nore=- |
last post by:
I'm trying to open a new window when a button is clicked.
I'm using the following code in my page_load to do so.
Dim myScript As String = "<script language=javascript> function
loadWin() {"
myScript += "window.open('testl.aspx')"
|
by: abcd |
last post by:
I am novice asp.net programmer.
I have xyz.js file which has resuable functions. I have asp.net form
abcd.aspx and the code behind file abcd.aspx.cs, I want to put a 'Help'
button when clicked it will open a window and open the required file for
me.
I am have issues
1.I tried calling my xyz.js function i.e. ShowHelp in the call like in my
|
by: thisis |
last post by:
Hi All,
i have this.asp page:
<script type="text/vbscript">
Function myFunc(val1ok, val2ok)
' do something ok
myFunc = " return something ok"
End Function
</script>
|
by: AnuSumesh |
last post by:
Hi All,
I am trying to call RDP on click of link.
'n' I am using following code to do this:
<script language="javascript">
function setip(ip)
{
var wshell;
|
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
| |
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |