Content Page Controls Disappear When I Click OK on Javascript Alertbox

E

e_spork

I am using Page.ClientScript.RegisterStartupScript to throw up a
Javascript alert box. When I click OK on the alert box, all the
controls on my page disappear and I don't understand why. I can View
Source in the browser and see all the controls so I know they are
there, yet they vanish once I click OK. This is happening on a
Content page. The browser is IE 6.0.2900 and I'm running it inside of
Visual Studio 2005.

My master page consists of nothing more than a couple of <div>s and a
ContentPlaceHolder. My content page contains a user control (.ascx)
and an Insert button. The user control is basically the UI for an
underlying business object which contains its own validation logic.
For testing purposes, I have coded the Page_Load method to throw up an
alert() box on any postback. Here's the code, in brief:

<%@ Page Language="C#" MasterPageFile="~/MasterPage.master"
AutoEventWireup="true" CodeFile="AddUser.aspx.cs"
Inherits="DesktopCl_AddUser" %>
<%@ MasterType TypeName="MasterPage" %>
<%@ Register Src="../ucDesktopClUser.ascx" TagName="ucDesktopClUser"
TagPrefix="uc1" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder1"
Runat="Server">

<h1>Add User</h1><br />

<uc1:ucDesktopClUser ID="UcDesktopClUser1" runat="server" />
<asp:Button ID="InsertButton" runat="server"
CausesValidation="True" CommandName="Insert"
Text="Insert" OnClick="InsertButton_Click"></asp:Button>

</asp:Content>

- - - - - - - - - - - - - - - -

protected void Page_Load(object sender, EventArgs e)
{

if (IsPostBack)
{
string script = "alert(\" Test \");";
ClientScriptManager csm = this.ClientScript;
if (!csm.IsStartupScriptRegistered(this.GetType(),
"ErrorPopup"))
csm.RegisterStartupScript(this.GetType(),
"ErrorPopup", script, true);
}
{
DesktopClUser user = new DesktopClUser();
UcDesktopClUser1.User = user;
}

}

- - - - - - - - - - - - - - - -

This is the script emitted by RegisterStartupScript:

<script type="text/javascript">
<!--
alert(" Test ");// -->
</script>

Why does clicking on the alert() box cause the controls to disappear?
Is this a browser issue?
 

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,968
Messages
2,570,152
Members
46,698
Latest member
LydiaHalle

Latest Threads

Top