Newbie, how to display a messagebox always on top

Discussion in 'ASP .Net Building Controls' started by verci, Sep 11, 2006.

  1. verci

    verci Guest

    Hi, sorry if this seems stupid, please have patience.

    I'm running Win XP sp2, VS 2005 Tem, SQL Sever 2005, I've been using a
    gridview to display my DB information, on the Gridview_RowUpadating event
    handler I validate if the value entered already exist en the DB using the
    following.

    Protected Sub GridView1_RowUpdating(ByVal sender As Object, ByVal e As
    System.Web.UI.WebControls.GridViewUpdateEventArgs) Handles
    GridView1.RowUpdating

    Dim valor As String = e.NewValues("ProductName").ToString

    If RunQueryDr(valor) = True Then

    e.Cancel = True

    MsgBox("This value already exist!", MsgBoxStyle.ApplicationModal +
    MsgBoxStyle.Critical, "Error")

    Return

    End If

    End Sub

    I want to display the message box always on top of other windows, so the
    user can't minimize it or even worst keep trying to update the record and
    thus opening various error message boxes, I've tried the JavaScript
    openwindow and alert functions with no success.

    Thanks
    verci, Sep 11, 2006
    #1
    1. Advertising

  2. A simple answer is that javascript alert function is the way to go. You can
    pass the message to show to the client-side where it can be picked up and
    displayed. The standard way of passing information between server and client
    is using hidden input controls. Put this line in your web form:
    <input type="hidden" runat="server" id="inhMessage"/>

    The server code will set the message as

    inhMessage.Value="This value already exist!"

    The client code will access it as
    <script>
    function checkMessage(){
    if(myForm.inhMessage.Value<>'')
    {
    alert(myForm.inhMessage.Value);
    myForm.inhMessage.Value='';
    }
    }
    </script>
    ....
    <body onload='checkMessage()'/>

    --
    Eliyahu Goldin,
    Software Developer & Consultant
    Microsoft MVP [ASP.NET]


    "verci" <> wrote in message
    news:%...
    > Hi, sorry if this seems stupid, please have patience.
    >
    > I'm running Win XP sp2, VS 2005 Tem, SQL Sever 2005, I've been using a
    > gridview to display my DB information, on the Gridview_RowUpadating event
    > handler I validate if the value entered already exist en the DB using the
    > following.
    >
    > Protected Sub GridView1_RowUpdating(ByVal sender As Object, ByVal e As
    > System.Web.UI.WebControls.GridViewUpdateEventArgs) Handles
    > GridView1.RowUpdating
    >
    > Dim valor As String = e.NewValues("ProductName").ToString
    >
    > If RunQueryDr(valor) = True Then
    >
    > e.Cancel = True
    >
    > MsgBox("This value already exist!", MsgBoxStyle.ApplicationModal +
    > MsgBoxStyle.Critical, "Error")
    >
    > Return
    >
    > End If
    >
    > End Sub
    >
    > I want to display the message box always on top of other windows, so the
    > user can't minimize it or even worst keep trying to update the record and
    > thus opening various error message boxes, I've tried the JavaScript
    > openwindow and alert functions with no success.
    >
    > Thanks
    >
    Eliyahu Goldin, Sep 12, 2006
    #2
    1. Advertising

  3. Javascript is case-sencitive. Should be

    function checkMessage(){
    if(myForm.inhMessage.value<>'')
    {
    alert(myForm.inhMessage.value);
    myForm.inhMessage.value='';
    }
    }

    If you still get error messages, specify the error text.

    --
    Eliyahu Goldin,
    Software Developer & Consultant
    Microsoft MVP [ASP.NET]


    "verci" <> wrote in message
    news:...
    > Hi
    > Can you please take a look at my code , what am I doing wrong? I get 2
    > error messages :
    >
    >
    > <%@ Page Language="VB" AutoEventWireup="false" CodeFile="Default3.aspx.vb"
    > Inherits="Default3" %>
    >
    > <!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>
    >
    > <script>
    >
    > function checkMessage(){
    >
    > if(myForm.inhMessage.Value<>'')
    >
    > {
    >
    > alert(myForm.inhMessage.Value);
    >
    > myForm.inhMessage.Value='';
    >
    > }
    >
    > }
    >
    > </script>
    >
    > </head>
    >
    > <body onload='checkMessage()'>
    >
    > <form id="form1" runat="server">
    >
    > <input type="hidden" runat="server" id="inhMessage"/>
    >
    > <div>
    >
    > <asp:GridView ID="GridView1" runat="server" AllowPaging="True"
    > AutoGenerateColumns="False"
    >
    > DataKeyNames="ProductID" DataSourceID="SqlDataSource1">
    >
    > <Columns>
    >
    > <asp:BoundField DataField="ProductID" HeaderText="ProductID"
    > InsertVisible="False"
    >
    > ReadOnly="True" SortExpression="ProductID" />
    >
    > <asp:TemplateField HeaderText="ProductName" SortExpression="ProductName">
    >
    > <EditItemTemplate>
    >
    > <asp:TextBox ID="TextBox1" runat="server" Text='<%# Bind("ProductName")
    > %>'></asp:TextBox>
    >
    > <asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server"
    > ControlToValidate="TextBox1"
    >
    > ErrorMessage="Valor requerido"
    > Text="*"></asp:RequiredFieldValidator>&nbsp;
    >
    > </EditItemTemplate>
    >
    > <ItemTemplate>
    >
    > <asp:Label ID="Label1" runat="server" Text='<%# Bind("ProductName")
    > %>'></asp:Label>
    >
    > </ItemTemplate>
    >
    > </asp:TemplateField>
    >
    > <asp:CommandField ShowEditButton="True" />
    >
    > </Columns>
    >
    > </asp:GridView>
    >
    > &nbsp; &nbsp;
    >
    > <asp:ValidationSummary ID="ValidationSummary1" runat="server"
    > Style="z-index: 100;
    >
    > left: 449px; position: absolute; top: 37px" DisplayMode="List"
    > Font-Bold="True" ShowMessageBox="True" ShowSummary="False" />
    >
    > &nbsp;
    >
    > <asp:SqlDataSource ID="SqlDataSource1" runat="server"
    > ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString %>"
    >
    > SelectCommand="SELECT [ProductID], [ProductName] FROM [Products] order by
    > ProductID"
    >
    > UpdateCommand="Update Products set ProductName=@Productname where
    > ProductID=@ProductID"></asp:SqlDataSource>
    >
    > </div>
    >
    > </form>
    >
    > </body>
    >
    > </html>
    >
    >
    >
    > "Eliyahu Goldin" <> wrote in
    > message news:...
    >>A simple answer is that javascript alert function is the way to go. You
    >>can
    >> pass the message to show to the client-side where it can be picked up and
    >> displayed. The standard way of passing information between server and
    >> client
    >> is using hidden input controls. Put this line in your web form:
    >> <input type="hidden" runat="server" id="inhMessage"/>
    >>
    >> The server code will set the message as
    >>
    >> inhMessage.Value="This value already exist!"
    >>
    >> The client code will access it as
    >> <script>
    >> function checkMessage(){
    >> if(myForm.inhMessage.Value<>'')
    >> {
    >> alert(myForm.inhMessage.Value);
    >> myForm.inhMessage.Value='';
    >> }
    >> }
    >> </script>
    >> ...
    >> <body onload='checkMessage()'/>
    >>
    >> --
    >> Eliyahu Goldin,
    >> Software Developer & Consultant
    >> Microsoft MVP [ASP.NET]
    >>
    >>
    >> "verci" <> wrote in message
    >> news:%...
    >>> Hi, sorry if this seems stupid, please have patience.
    >>>
    >>> I'm running Win XP sp2, VS 2005 Tem, SQL Sever 2005, I've been using a
    >>> gridview to display my DB information, on the Gridview_RowUpadating
    >>> event
    >>> handler I validate if the value entered already exist en the DB using
    >>> the
    >>> following.
    >>>
    >>> Protected Sub GridView1_RowUpdating(ByVal sender As Object, ByVal e As
    >>> System.Web.UI.WebControls.GridViewUpdateEventArgs) Handles
    >>> GridView1.RowUpdating
    >>>
    >>> Dim valor As String = e.NewValues("ProductName").ToString
    >>>
    >>> If RunQueryDr(valor) = True Then
    >>>
    >>> e.Cancel = True
    >>>
    >>> MsgBox("This value already exist!", MsgBoxStyle.ApplicationModal +
    >>> MsgBoxStyle.Critical, "Error")
    >>>
    >>> Return
    >>>
    >>> End If
    >>>
    >>> End Sub
    >>>
    >>> I want to display the message box always on top of other windows, so the
    >>> user can't minimize it or even worst keep trying to update the record
    >>> and
    >>> thus opening various error message boxes, I've tried the JavaScript
    >>> openwindow and alert functions with no success.
    >>>
    >>> Thanks
    >>>

    >>
    >>

    >
    >
    >
    Eliyahu Goldin, Sep 13, 2006
    #3
    1. Advertising

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. Paul Wilson

    how to display a MessageBox in ASP.net

    Paul Wilson, Jun 21, 2004, in forum: ASP .Net
    Replies:
    3
    Views:
    4,131
    =?Utf-8?B?QW5vdGhlciBvcHRpb24=?=
    Jun 21, 2004
  2. soundar rajan
    Replies:
    2
    Views:
    3,535
    =?Utf-8?B?RG90TmV0SmVyb21l?=
    Feb 24, 2005
  3. Replies:
    3
    Views:
    6,658
  4. Steve Kershaw

    How can I display a MessageBox in ASP.NET?

    Steve Kershaw, May 26, 2006, in forum: ASP .Net
    Replies:
    5
    Views:
    3,907
    Steve C. Orr [MVP, MCSD]
    May 26, 2006
  5. verci

    Newbie, how to display a messagebox always on top

    verci, Sep 11, 2006, in forum: ASP .Net Datagrid Control
    Replies:
    2
    Views:
    370
    Eliyahu Goldin
    Sep 13, 2006
Loading...

Share This Page