Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / February 2008

Tip: Looking for answers? Try searching our database.

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

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Radu - 01 Feb 2008 21:39 GMT
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.
Mark Rae [MVP] - 01 Feb 2008 22:36 GMT
> 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;
}

Signature

Mark Rae
ASP.NET MVP
http://www.markrae.net

Radu - 04 Feb 2008 14:26 GMT
Thank you very much, Mark - this solved my problem. Have a great
day ! :-)
Alex.

> > Can someone, please, guide me out of this
>
[quoted text clipped - 11 lines]
> Mark Rae
> ASP.NET MVPhttp://www.markrae.net

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.