473,398 Members | 2,404 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,398 software developers and data experts.

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 5453
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.Add( 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 HtmlGenericControl 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.net> wrote in message
news:a3*************************@posting.google.co m...
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=\"javascript\">";
msg += "alert('Your message here');";
msg += "</script>";
Response.Write( msg );

ec*@bezeqint.net (Manu) wrote in message news:<a3*************************@posting.google.c om>...
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
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 (...
3
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...
4
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...
9
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...
6
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,...
9
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,...
7
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...
1
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...
1
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...
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
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...
0
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...
0
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...
0
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,...

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.