Alert in web user control

Posted by Vatcharm under ASP.NET AJAX on 2/14/2010 | Views : 5287 | Status : [Member] | Replies : 4
Hi everyone
I'm a new member.This is first post my problem is
I have webpage.aspx that contain web user control.
Code in webusercontrol.ascx.cs
Page.RegisterStartupScript("myAlert", "<script>alert('Item Insert Successfull');</script>");
when is run webpags.aspx "myalert" not display
help me please




Responses

Posted by: Vuyiswamb on: 2/15/2010 [Member] [MVP] [Administrator] NotApplicable

Up
0
Down
Good Day Vatcharm

I think you are not doing it Correct. This is what i did. i created a usercontrol that is defined like this

<%@ Control Language="C#" AutoEventWireup="true" CodeFile="WebUserControl.ascx.cs" Inherits="WebUserControl" %>


and the server side is like this

using System;

using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;

public partial class WebUserControl : System.Web.UI.UserControl
{
protected void Page_Load(object sender, EventArgs e)
{
Page.RegisterStartupScript("myAlert", "<script>alert('Item Insert Successfull');</script>");
}
}


and dropped the usercontrol in a domain aspx page like this

<%@ Page Language="C#" AutoEventWireup="true"  CodeFile="Default.aspx.cs" Inherits="_Default" %>


<%@ Register Src="WebUserControl.ascx" TagName="WebUserControl" TagPrefix="uc1" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<uc1:WebUserControl ID="WebUserControl1" runat="server" />

</div>
</form>
</body>
</html>


and when i ran this it gave me this

Item Insert Successfull'


Thank you for Posting at Dotnetfunda

Vuyiswa Maseko


Thank you for posting at Dotnetfunda
[Administrator]

Vatcharm, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Vatcharm on: 2/15/2010 [Member] Starter

Up
0
Down
Oh..
my webpage.aspx containt
maseterpage

thank you

Vatcharm, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Vuyiswamb on: 2/15/2010 [Member] [MVP] [Administrator] NotApplicable

Up
0
Down
Is youe Problem Resolved ?

If yes , Please mark it as resolved.

Thank you for posting at Dotnetfunda

Vuyiswa Maseko

Thank you for posting at Dotnetfunda
[Administrator]

Vatcharm, if this helps please login to Mark As Answer. | Alert Moderator

Posted by: Nishithraj on: 2/18/2010 [Member] Bronze

Up
0
Down
Then you can try to include that control in contentplaceholder

Mark this as answer, if it is.....

With regards
Nishithraj Narayanan

Vatcharm, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response