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

Conditional Javascript Call

Is there a way to conditionally call a Javascript when a Page loads, say: if
txtMyText.text <> string.empty then <Javascript>? Or should it all be calles
using Javascript?

TIA!
Nov 19 '05 #1
3 1776
You can, but since this is on PostBack you could easily check this clientside
before the PostBack occurs...
If you are trying to so some sort of validation then I would do it will all
Javascript and stop the PostBack from occuring at all....

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

"TCORDON" wrote:
Is there a way to conditionally call a Javascript when a Page loads, say: if
txtMyText.text <> string.empty then <Javascript>? Or should it all be calles
using Javascript?

TIA!

Nov 19 '05 #2
I'm confused by your question.

When the page loads server side, why would you want to call Javascript from
code behind ??

--
Best Regards

The Inimitable Mr Newbie º¿º
"TCORDON" <tc******@hotmail.com> wrote in message
news:e$**************@tk2msftngp13.phx.gbl...
Is there a way to conditionally call a Javascript when a Page loads, say:
if txtMyText.text <> string.empty then <Javascript>? Or should it all be
calles using Javascript?

TIA!

Nov 19 '05 #3
I think you are looking for RegisterStartupScript ..

in your Page_Load()

string jscript = "<script>alert("1234");</script>";

if(txtMyText.text.Length > 0)
{
Page.RegisterStartupScript("somename", jscript );
}


"TCORDON" wrote:
Is there a way to conditionally call a Javascript when a Page loads, say: if
txtMyText.text <> string.empty then <Javascript>? Or should it all be calles
using Javascript?

TIA!

Nov 19 '05 #4

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

Similar topics

8
by: neblackcat | last post by:
Would anyone like to comment on the following idea? I was just going to offer it as a new PEP until it was suggested that I post it here for comment & consideration against PEP 308. I'm far...
1
by: Orest Kinasevych | last post by:
Okay, I made sense of the earlier suggestions and realized I was on the right track -- I appreciate the feedback which got me to this point. The suggestions posted here indeed worked and...
4
by: TheKeith | last post by:
I just wrote the following script for something I'm working on: ---------------------------------------------------------------------------- ------------------- <html> <head> <script...
28
by: Benjamin Niemann | last post by:
Hello, I've been just investigating IE conditional comments - hiding things from non-IE/Win browsers is easy, but I wanted to know, if it's possible to hide code from IE/Win browsers. I found...
3
by: jurujuba | last post by:
Hi, I want to write iteration- and conditional-tags with asp.net, but I found nothing about it in books, MSDN or online-articels. Could someone please explain me or post a link to an article...
8
by: Olov Johansson | last post by:
I just found out that JavaScript 1.5 (I tested this with Firefox 1.0.7 and Konqueror 3.5) has support not only for standard function definitions, function expressions (lambdas) and Function...
44
by: petermichaux | last post by:
Hi, I have been using the following line of code to create an object called "Serious" if it doesn't already exist. if (Serious == null) {var Serious = {};} This works in the scripts I use...
1
by: Marek | last post by:
I use VS2005 with framework 2.0 and I just found a behavior I consider odd. Here is the code that illustrates th eproblem: public static void MethodA() { MethodB() } #if DEBUG
4
by: rocketeer | last post by:
I've a set of Javascript classes that maintain state. For example, gm.js might be: var GroupManager { groups: {} }; Over time I add new groups to the list: GroupManager.groups = myGroup; ...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
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?

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.