How to inject JS messagebox code without messing the looks of the

Hi. I have this very big question mark: In the rowupdating event of a
gridview I need to cancel the updating and to inform the user why that
happens, like in this code:

protected void GridView1_RowUpdating(object sender,
System.Web.UI.WebControls.GridViewUpdateEventArgs e)
{
if (some condition)
{
string strMessage;
strMessage = "This record is not editable because blah-blah-blah !";
Response.Write("<script language='javascript'>alert('" + strMessage +
"');</script>");
e.Cancel = true;
}
}

It... works but it looks awful - first the whole screen goes blank,
and in front of this blank screen I can see my messagebox. After I
dismiss it, the screen gets populated as before, except that the font
is now probably twice as big as before !!!!???? (It is HUGE !)

Also, the cancel event is still not executed i.e. the user still sees
the UPDATE and the CANCEL link buttons, and he has to click on the
CANCEL one...... However, upon clicking on the CANCEL button, the
things go back in order (the font becomes normal again) (Huh ???)

Can someone, please, guide me out of this, (explain me what's
happening and how to do this properly) ?

Thanks a lot
Alex.
Radu [ Fr, 01 Februar 2008 22:39 ] [ ID #1921670 ]

Re: How to inject JS messagebox code without messing the looks of the page ?

"Radu" <cuca_macaii2000 [at] yahoo.com> wrote in message
news:6b917c2c-17c8-4d4c-8f35-abea8491c298 [at] e10g2000prf.google groups.com...

> Can someone, please, guide me out of this

if (some condition)
{
string strMessage;
strMessage = "This record is not editable because blah-blah-blah !";
ClientScript.RegisterStartupScript(GetType(), "notEditable", "alert('" +
strMessage + "');", true);
e.Cancel = true;
}


--
Mark Rae
ASP.NET MVP
http://www.markrae.net
mark [ Fr, 01 Februar 2008 23:36 ] [ ID #1921676 ]
Microsoft » microsoft.public.dotnet.framework.aspnet » How to inject JS messagebox code without messing the looks of the

Vorheriges Thema: How do I mimic the "Silverlight" popup behavior that MS is using?
Nächstes Thema: Can't get rid of this error. ListView. Please, need help.