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

Discussion in 'ASP .Net' started by Radu, Feb 1, 2008.

  1. Radu

    Radu Guest

    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, Feb 1, 2008
    #1
    1. Advertisements

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

    "Radu" <> wrote in message
    news:...

    > 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 Rae [MVP], Feb 1, 2008
    #2
    1. Advertisements

  3. Radu

    Radu Guest

    Thank you very much, Mark - this solved my problem. Have a great
    day ! :)
    Alex.



    On Feb 1, 5:36 pm, "Mark Rae [MVP]" <> wrote:
    > "Radu" <> wrote in message
    >
    > news:...
    >
    > > 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 MVPhttp://www.markrae.net
     
    Radu, Feb 4, 2008
    #3
    1. Advertisements

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Anders K. Jacobsen [DK]

    How to stop HTML View from messing up HTML code

    Anders K. Jacobsen [DK], Jan 21, 2005, in forum: ASP .Net
    Replies:
    3
    Views:
    804
    Anders K. Jacobsen [DK]
    Jan 22, 2005
  2. Keith Murray
    Replies:
    1
    Views:
    834
    Chris R. Timmons
    Oct 2, 2005
  3. Alex Paransky
    Replies:
    5
    Views:
    1,643
    harrison_ford
    Feb 23, 2008
  4. Xah Lee
    Replies:
    10
    Views:
    648
    Fredrik Lundh
    Jan 17, 2005
  5. Paul Boddie
    Replies:
    1
    Views:
    503
  6. Peña, Botp

    inject does not inject last value

    Peña, Botp, Aug 7, 2006, in forum: Ruby
    Replies:
    4
    Views:
    506
    Peña, Botp
    Aug 7, 2006
  7. Jake Barnes
    Replies:
    6
    Views:
    292
    David Mark
    Apr 30, 2009
  8. Zhiguo
    Replies:
    1
    Views:
    226
    Michael Haufe (\TNO\)
    Dec 10, 2009
Loading...