473,666 Members | 2,058 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

does asp.net provide a solution to post back from javascript to raise an server-side event in the page?

i want to raise an event on the server with a javascript call on the client.
i found a solution but i think its not so elegant. the solution is:
i call __doPostBack("R efreshPage", ""); from javascript and check in the
Page_Load routine :
bool refreshPage = Request.Form["__EVENTTAR GET"] == "RefreshPag e";

i could do it with __doPostBack("" , "RefreshPag e"); and ["__EVENTARGUMEN T"]
== "RefreshPag e"

i could also add a hidden input control to the form, and set its value to
something and check its value in the Page_Load event handler..

i also tried
Page.GetPostBac kEventReference (this, "RefreshPag e");

it writes out : __doPostBack("" , "RefreshPag e");

i called that function in javascript to cause an postback and in the page i
overrode the RaisePostBackEv ent method:

protected override void RaisePostBackEv ent(IPostBackEv entHandler
sourceControl, string eventArgument)

{

if(eventArgumen t == "RefreshPag e")

{

//Do something..

}

base.RaisePostB ackEvent (sourceControl, eventArgument);

}

but this method doesnt be called by the asp.net..

it is suprising that no elegant solution is provided by microsoft. does
anybody know better way doing this?
Nov 19 '05 #1
2 4363
It's not that it's MS "not providing an elegant solution", its just that you
are dealing with apples and oranges....
Anyway, you're really pretty much on the right track. You'll have to force
the page to do a postback and catch some variable/value and manually fire
your event.

--
Curt Christianson
site: http://www.darkfalz.com
blog: http://blog.darkfalz.com

"The Crow" wrote:
i want to raise an event on the server with a javascript call on the client.
i found a solution but i think its not so elegant. the solution is:
i call __doPostBack("R efreshPage", ""); from javascript and check in the
Page_Load routine :
bool refreshPage = Request.Form["__EVENTTAR GET"] == "RefreshPag e";

i could do it with __doPostBack("" , "RefreshPag e"); and ["__EVENTARGUMEN T"]
== "RefreshPag e"

i could also add a hidden input control to the form, and set its value to
something and check its value in the Page_Load event handler..

i also tried
Page.GetPostBac kEventReference (this, "RefreshPag e");

it writes out : __doPostBack("" , "RefreshPag e");

i called that function in javascript to cause an postback and in the page i
overrode the RaisePostBackEv ent method:

protected override void RaisePostBackEv ent(IPostBackEv entHandler
sourceControl, string eventArgument)

{

if(eventArgumen t == "RefreshPag e")

{

//Do something..

}

base.RaisePostB ackEvent (sourceControl, eventArgument);

}

but this method doesnt be called by the asp.net..

it is suprising that no elegant solution is provided by microsoft. does
anybody know better way doing this?

Nov 19 '05 #2
i cant see apples and oranges around what do you mean? and why
raisepostbackev ent doesnt raise? if it wont raise, why Page class expose
that method? i know it raises when for example i inherit from button, i
expect same thing when i inherit from page, because its a control too.
Nov 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

12
2307
by: Fred Pacquier | last post by:
First off, sorry for this message-in-a-bottle-like post... I haven't been able to phrase my questions well enough to get a meaningful answer from Google in my research. OTOH, it is standard flattery (but true) that this group has a bunch of the nicest and most knowledgeable Usenet people around, and I know for a fact that there are some pretty good spam- related tools written in Python, so I thought I might get away with it :-) Yes,...
3
1798
by: Duane Phillips | last post by:
Greetings. Can an app be developed in .Net to deploy like local installed apps, and then later reuse that code and object set to deploy on a web server? I have read a little about WEB vs. RICH vs. SMART in .Net. Still vague as to what path(s) to pursue. Background:
16
1541
by: Phil Powell | last post by:
The customer made a wild request: they want on their admin panel a textarea that will display an existing resume. This textarea, however, must have a dynamic width, one that "fills the screen width of any sized screen". Sorry but I cannot fathom how to do this! <textarea name="resume" cols="108" rows="29" wrap="physical><?= $resume ?></textarea>
6
4734
by: Henri | last post by:
Very strange problem : if I write: <asp:TextBox runat="server" id="myBox" /> the control's ViewState stays always empty, so it loses its properties if it's not always displayed. But if I write:
1
1955
by: M | last post by:
Hi everybody, I have a Web form with something like: <form id="Form1" method="post" onsubmit="javascript:submitForm();" runat="server"> I need the JavaScript function submitForm() to execute everytime the form is submitted. I also have two RadioButtons with AutoPostBack set to true.
2
2182
by: sunilthk | last post by:
Hi All, I have a question. If javascript is disabled how asp.net determines which control has caused the post back. As we know that when we clicks on the button the buttons name goes with posted data, so asp.net can detrmine which btn caused the post back. In case of dropdown lists(if auto post back is true) _doPostback javascript function is called which assigns the name of the control in _EVENTTARGET hidden variable, by this ASP.NET...
25
9576
by: FAQ server | last post by:
----------------------------------------------------------------------- FAQ Topic - Why does parseInt('09') give an error? ----------------------------------------------------------------------- The parseInt function decides what base the number is by looking at the number. By convention it assumes that any number beginning with 0x is Hexadecimal, and otherwise any number beginning with 0 is Octal. To force use of base 10 add a second...
14
3474
by: webEater | last post by:
I have a problem, it's not browser specific, and I don't get a solution. I have an (X)HTML document, I show you a part of it: .... <!--<div class="pad">--> <div id="eventImages"><img src="" id="eventImage0" class="eventImage"><img src="" id="eventImage1" class="eventImage"></div>
5
7997
by: ThomasJ | last post by:
Ok so I have a DataGrid of which I have added checkboxes for every row, and a delete button. All of the code for checking and actually deleting the rows runs fine, however, the javascript I have attached to this asp button does not seem to be running properly. Its a confirm box that while the code runs properly. A false value does not stop the post back to the server. Any ideas on this would be greatly appreciated. If you would like to see...
34
2779
by: Creativ | last post by:
Why does Thread class not support IDisposable? It's creating quite some problem. Namely, it can exhaust the resource and you have not control over it.
0
8444
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, 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...
0
8356
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,...
0
8869
Oralloy
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...
0
8781
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
0
8639
tracyyun
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...
0
7386
agi2029
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...
0
5664
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4368
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2771
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.