473,698 Members | 2,628 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to trigger client script from server script?

In my ASPX code I would like to open a new window, send a message box,
create an alert window etc. The logic when to do the above is
implemented in the server side, as it is depended upon Database
information. (i.e. open an alert window when a record was not found in
the database.)
As I know opening such windows can be done on the client side only.
How can I trigger these scripts from the SERVER side?
Is there an example explaining this?
Nov 15 '05 #1
2 5476
Hi Manu,

Well you have several options that are all based on the same idea, you have
a server side control , a Literal to me more precise , where you pass the
code or set the variables needed at the client, the value of this Text
property goes unchanged to the client, therefore you can do something like:
literal.Text= "<script> Alert('Hello'); </script>";
this.Controls.A dd( literal);

Now this is the basic idea, from there you have to code what you need, you
can set a function in the OnLoad event of the Body that call a function ,
and you use the literal to set a variable to decide what to do, etc

Another idea without the use of the Literal control may be setting the value
of OnLoad to one of several functions already defined in the HTML page, this
is useful if you have a predefined number of messages that do not change
( like a not found message ) , for this you have to mark the Body with
runat="server":
<body ID="Body" runat="server">

then in the server side you declare it like:
protected HtmlGenericCont rol Body;

and then add the correct function to the OnLoad using
Body.Attributes .Add("OnLoad", "FunctionToCall ");
Hope this help,

--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation

"Manu" <ec*@bezeqint.n et> wrote in message
news:a3******** *************** **@posting.goog le.com...
In my ASPX code I would like to open a new window, send a message box,
create an alert window etc. The logic when to do the above is
implemented in the server side, as it is depended upon Database
information. (i.e. open an alert window when a record was not found in
the database.)
As I know opening such windows can be done on the client side only.
How can I trigger these scripts from the SERVER side?
Is there an example explaining this?

Nov 15 '05 #2
Send the javascript to the client via Response.Write. ..

string msg = "<script language=\"java script\">";
msg += "alert('You r message here');";
msg += "</script>";
Response.Write( msg );

ec*@bezeqint.ne t (Manu) wrote in message news:<a3******* *************** ***@posting.goo gle.com>...
In my ASPX code I would like to open a new window, send a message box,
create an alert window etc. The logic when to do the above is
implemented in the server side, as it is depended upon Database
information. (i.e. open an alert window when a record was not found in
the database.)
As I know opening such windows can be done on the client side only.
How can I trigger these scripts from the SERVER side?
Is there an example explaining this?

Nov 15 '05 #3

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

Similar topics

6
3443
by: Dave C. | last post by:
Hello, I have created the following trigger: CREATE TRIGGER tr_UDFTest ON UserDefinedFields FOR INSERT, UPDATE AS DECLARE @foobar varchar(100) SELECT @foobar= foobar FROM inserted IF ( @foobar = 'foobar') INSERT INTO LogTable (LogText) values ('Found foobar')
3
10843
by: Terri | last post by:
I'm using xp_cmdshell to output a text file from a trigger like this CREATE TRIGGER ON tblApplications FOR INSERT AS DECLARE @FirstName varchar(75) DECLARE @LastName varchar(75) Declare @strcmdshell varchar(150)
4
6987
by: Pecos Bill | last post by:
Salve, non riesco a disabilitare un trigger su sqlserver nè da query analyzer, nè da enterprise manager. In pratica tal cosa riuscivo a farla in Oracle con TOAD, mentre qui non riesco. Mi interessa disattivarlo senza cancellarlo per poi riattivarlo al bisogno senza rilanciare lo script di creazione. Grazie a tutti Hi I need to disable a DB trigger and I'm not able to do this neither with query analyzer, neither with enterprise manager.
9
11229
by: Lauren Quantrell | last post by:
Is there a way to create a text file (such as a Windows Notepad file) by using a trigger on a table? What I want to do is to send a row of information to a table where the table: tblFileData has only one column: txtOutput I want to use the DB front end (MS Access) to send the text string to the SQL backend, then have the SQL Server create a file to a path, such as F:/myfiledate.txt that holds the text in txtOutput, then the trigger...
6
2287
by: Marc | last post by:
How could I directly trigger a very simple on localhost and a known port listening server from my internet browser client? Local host means the little server would be running on the client machine, where my browser resides. Browser would be IE, O.S. Windows 2000 or XP, and it's for an intranet application. The goal of the little server on the localhost client side would be to trigger a scanner, with the TWAIN library. Also this server is...
9
9308
by: Ots | last post by:
I'm using SQL 2000, which is integrated with a VB.NET 2003 app. I have an Audit trigger that logs changes to tables. I want to apply this trigger to many different tables. It's the same trigger, with the exception of the table name. I could manually change the table name in the trigger and create it, over and over, but I'd like to automate this - by iterating through the collection of tables and passing the tablename to something that...
7
3063
by: RogBaker | last post by:
I haven't gotten a response yet, so I moved this from another group. I have been working on this for 2 days so if anyone has any ideas, I would be grateful. I have a 3rd party program that creates and populates tables in my SQL Server 2005 database. The program fails on the inserts on "tblB" because the field it creates is too small for the data that it is trying to put in it
1
7014
by: daonho | last post by:
I tried to use javascript to trigger up the button click function when user press enter key from the textbox. This function work fine with a single button click such has login page. However, if the page has multiple button such login page with a search function somewhere around, then it's not respond properly. I have attached a brief example of two text boxes and two button. When ever a key is press on textbox one, I want to trigger...
1
5346
by: Jeff | last post by:
hi asp.net 3.5 (project upgraded from asp.net 2.0). are using vwd2008 express now This is my first ajax attempt. The code below shows a TextBox and a ListBox. The idea I was trying to accomplish was that the items in the ListBox was automatically filtered as the user type text into the textbox... But nothing happens. The OnTextChanged event isn't even fired when I type in the textbox.
0
8683
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
9170
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
9031
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...
1
8902
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,...
0
8873
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
7740
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
5862
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();...
1
3052
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
2
2339
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.