Client side alert

A

axapta

Hi Guys,
I'm using this code in my asp.net page. It runs from a button webcontrol.

Dim sbJScript As String

sbJScript = "<script language = ""javascript"">"
sbJScript = sbJScript & "window.alert('Please choose either
Allocations or Homelessness');"
sbJScript = sbJScript & "window.close();"
sbJScript = sbJScript & "</script>"
litScript.Text = sbJScript
the alert doesn't appear and I get the following error: object reference not
set to an instance of an object. This occurs on the following line:
litScript.Text = sbJScript

How can I get an alert to appear client-side.
TIA
 
F

Family Tree Mike

I don't do a lot of ASP.Net stuff, but a couple of things strike me as being
odd in what you posted. The code you are showing would appear to be the
code-behind pages, so it runs server side. I don't know what you are trying
to send the script to, because the declaration of litScript is not shown. I
don't know how the script would get launched on the client.

Your error though seems to indicate that litScript is declared but not
initialized.
 
R

rowe_newsgroups

Hi Guys,
I'm using this code in my asp.net page.  It runs from a button webcontrol.

            Dim sbJScript As String

            sbJScript = "<script language = ""javascript"">"
            sbJScript = sbJScript & "window.alert('Please choose either
Allocations or Homelessness');"
            sbJScript = sbJScript & "window.close();"
            sbJScript = sbJScript & "</script>"
            litScript.Text = sbJScript
the alert doesn't appear and I get the following error: object reference not
set to an instance of an object.  This occurs on the following line:
litScript.Text = sbJScript

How can I get an alert to appear client-side.
TIA

When you debug, what object does the warning say is null?

Thanks,

Seth Rowe [MVP]
 

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

Top