Conditional Javascript Call

T

TCORDON

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!
 
G

Guest

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....
 
M

Mr Newbie

I'm confused by your question.

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

Guest

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 );
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,769
Messages
2,569,579
Members
45,053
Latest member
BrodieSola

Latest Threads

Top