PC Review


Reply
Thread Tools Rate Thread

Content Page Controls Disappear When I Click OK on Javascript Alertbox

 
 
e_spork@yahoo.com
Guest
Posts: n/a
 
      23rd Jan 2008
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?
 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Dynamically program User controls in a Master page from a content page Dinu Microsoft ASP .NET 1 31st Jul 2007 12:56 PM
Call javascript from ASP.net content page weird0 Microsoft C# .NET 2 20th Apr 2007 01:16 PM
error: Only Content controls are allowed directly in a content page that contains Content controls. hazz Microsoft ASP .NET 2 27th Apr 2006 06:32 PM
Preloading content through javascript & server side controls Dave Harrington Microsoft ASP .NET 0 25th Oct 2004 06:40 PM
JavaScript in Content Page error Steven K Microsoft ASP .NET 0 9th Sep 2004 07:57 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:23 PM.