prompt user to save changes in datagrid editmode when they try to navigate away from page...how do y

Discussion in 'ASP .Net Building Controls' started by tafs7, Feb 4, 2004.

  1. tafs7

    tafs7 Guest

    Hello,

    I have a custom datagrid control that works great. But I was thinking
    about adding some functionality to it. Currently, I use the datagrid
    to display one record at a time, and with edit item templates, if you
    click
    the edit button, the datagrid becomes a nice form to make changes.
    Kinda like a big rolodex, and as you page you flip thru each record
    individually.

    My question is this: how can I have some kind of server side script
    (and probably client side javascript) on the pages that contain this
    datagrid control (there are quite a few...), so that it can detect if
    the grid is in edit mode and will confirm if the user wants to save
    the changes made, before clicking
    away to another link on the page that is not the 'save' link? This
    will be very similar to the windows forms 'Exit without saving?'
    popup, so if
    users make changes to a record and forget to push the save/update
    button, then decide to click somewhere else on the page, it will tell
    them..."hey
    you need to save!"

    If anyone has any ideas on how to implement this, please let me
    know. I appreciate all of your help. Below is a rough pseudo code of
    my datagrid control within an aspx file. Most of the logic for the
    datagrid control is in the assembly for the custom control itself
    (i.e. itemcreated, itemdatabound, init, load, edit/delete command)

    Regards,
    Thiago
    Web Developer

    <Grid:CustomDG id=MyDG runat="server"
    ShowHeader="True"
    AutoGenerateColumns="False"
    DBTable = "tblMyTable"
    DataKeyField = "MyKeyField"
    GridLines="None"
    Cellpadding="5"
    width="800"
    BackColor="FloralWhite"
    BorderColor="Navy"
    BorderStyle="solid"
    BorderWidth="1px"
    CssClass="panel"
    AllowPaging="True"
    PageSize="1"

    OnUpdateCommand="MyDG_Update"

    HeaderStyle-BackColor="lightgrey"
    HeaderStyle-Font-Name="Verdana"
    HeaderStyle-Font-Bold="True"
    HeaderStyle-HorizontalAlign="Right"

    FooterStyle-BackColor="lightgrey"
    FooterStyle-Font-Name="Verdana"
    FooterStyle-Font-Bold="True" >
    <Columns>
    <asp:TemplateColumn>
    <ItemTemplate>
    <TABLE cellSpacing="0" cellPadding="0" align="center" border="1"
    bordercolor="#696969" width="100%">
    <tr bgColor="LightSteelBlue">
    <td class="tblHead">Some Information:</td>
    </tr>
    <tr><td>
    <TABLE class="setText" id="tblReason" cellSpacing="1"
    cellPadding="4" width="100%" align="center" border="0">
    <tr>
    <td class="label">Field Name: </td>
    <td>
    <asp:Label id="lblMyLabel"
    CssClass="txtIn"
    Text='<%# DataBinder.Eval(Container, "DataItem.MyFieldName") %>'
    Runat="server"/>
    </td>
    </tr>
    </TABLE>
    </td></tr>
    </TABLE>
    </ItemTemplate>
    <EditItemTemplate>
    <TABLE cellSpacing="0" cellPadding="0" align="center" border="1"
    bordercolor="#696969" width="100%">
    <tr bgColor="LightSteelBlue">
    <td class="tblHead">Provider Information:</td>
    </tr>
    <tr><td>
    <TABLE class="setText" id="tblReason" cellSpacing="3" cellPadding="3"
    width="100%" align="center" border="0">
    <tr>
    <td class="label">Field Name: </td>
    <td>
    <asp:TextBox id="lblMyLabel"
    CssClass="txtIn"
    Text='<%# DataBinder.Eval(Container, "DataItem.MyFieldName") %>'
    </td></tr>
    </TABLE>
    </EditItemTemplate>
    </asp:TemplateColumn>
    </Columns>
    </Grid:CustomDG>
    ....

    I do the databinding, and all other required logic, in the custom
    control's source code (assembly).
     
    tafs7, Feb 4, 2004
    #1
    1. Advertising

  2. tafs7

    locitt Guest

    You can add javascript to all editing textbox (for instance) to detect
    changes in your grid and with all other buttons not the save/update grid
    ones, you can add js to check if there're some changes made to the grid. All
    is javascript !. Event onclose the ie window or popup window.

    just an idea.
    locitt.


    "tafs7" <> wrote in message
    news:...
    > Hello,
    >
    > I have a custom datagrid control that works great. But I was thinking
    > about adding some functionality to it. Currently, I use the datagrid
    > to display one record at a time, and with edit item templates, if you
    > click
    > the edit button, the datagrid becomes a nice form to make changes.
    > Kinda like a big rolodex, and as you page you flip thru each record
    > individually.
    >
    > My question is this: how can I have some kind of server side script
    > (and probably client side javascript) on the pages that contain this
    > datagrid control (there are quite a few...), so that it can detect if
    > the grid is in edit mode and will confirm if the user wants to save
    > the changes made, before clicking
    > away to another link on the page that is not the 'save' link? This
    > will be very similar to the windows forms 'Exit without saving?'
    > popup, so if
    > users make changes to a record and forget to push the save/update
    > button, then decide to click somewhere else on the page, it will tell
    > them..."hey
    > you need to save!"
    >
    > If anyone has any ideas on how to implement this, please let me
    > know. I appreciate all of your help. Below is a rough pseudo code of
    > my datagrid control within an aspx file. Most of the logic for the
    > datagrid control is in the assembly for the custom control itself
    > (i.e. itemcreated, itemdatabound, init, load, edit/delete command)
    >
    > Regards,
    > Thiago
    > Web Developer
    >
    > <Grid:CustomDG id=MyDG runat="server"
    > ShowHeader="True"
    > AutoGenerateColumns="False"
    > DBTable = "tblMyTable"
    > DataKeyField = "MyKeyField"
    > GridLines="None"
    > Cellpadding="5"
    > width="800"
    > BackColor="FloralWhite"
    > BorderColor="Navy"
    > BorderStyle="solid"
    > BorderWidth="1px"
    > CssClass="panel"
    > AllowPaging="True"
    > PageSize="1"
    >
    > OnUpdateCommand="MyDG_Update"
    >
    > HeaderStyle-BackColor="lightgrey"
    > HeaderStyle-Font-Name="Verdana"
    > HeaderStyle-Font-Bold="True"
    > HeaderStyle-HorizontalAlign="Right"
    >
    > FooterStyle-BackColor="lightgrey"
    > FooterStyle-Font-Name="Verdana"
    > FooterStyle-Font-Bold="True" >
    > <Columns>
    > <asp:TemplateColumn>
    > <ItemTemplate>
    > <TABLE cellSpacing="0" cellPadding="0" align="center" border="1"
    > bordercolor="#696969" width="100%">
    > <tr bgColor="LightSteelBlue">
    > <td class="tblHead">Some Information:</td>
    > </tr>
    > <tr><td>
    > <TABLE class="setText" id="tblReason" cellSpacing="1"
    > cellPadding="4" width="100%" align="center" border="0">
    > <tr>
    > <td class="label">Field Name: </td>
    > <td>
    > <asp:Label id="lblMyLabel"
    > CssClass="txtIn"
    > Text='<%# DataBinder.Eval(Container, "DataItem.MyFieldName") %>'
    > Runat="server"/>
    > </td>
    > </tr>
    > </TABLE>
    > </td></tr>
    > </TABLE>
    > </ItemTemplate>
    > <EditItemTemplate>
    > <TABLE cellSpacing="0" cellPadding="0" align="center" border="1"
    > bordercolor="#696969" width="100%">
    > <tr bgColor="LightSteelBlue">
    > <td class="tblHead">Provider Information:</td>
    > </tr>
    > <tr><td>
    > <TABLE class="setText" id="tblReason" cellSpacing="3" cellPadding="3"
    > width="100%" align="center" border="0">
    > <tr>
    > <td class="label">Field Name: </td>
    > <td>
    > <asp:TextBox id="lblMyLabel"
    > CssClass="txtIn"
    > Text='<%# DataBinder.Eval(Container, "DataItem.MyFieldName") %>'
    > </td></tr>
    > </TABLE>
    > </EditItemTemplate>
    > </asp:TemplateColumn>
    > </Columns>
    > </Grid:CustomDG>
    > ...
    >
    > I do the databinding, and all other required logic, in the custom
    > control's source code (assembly).
     
    locitt, Feb 5, 2004
    #2
    1. Advertising

  3. tafs7

    Eric Guest

    If you don't mind the behavior being limited to Internet Explorer, see the
    following article:

    http://www.codeproject.com/aspnet/EWSWebPt2.asp


    "tafs7" <> wrote in message
    news:...
    > Hello,
    >
    > I have a custom datagrid control that works great. But I was thinking
    > about adding some functionality to it. Currently, I use the datagrid
    > to display one record at a time, and with edit item templates, if you
    > click
    > the edit button, the datagrid becomes a nice form to make changes.
    > Kinda like a big rolodex, and as you page you flip thru each record
    > individually.
    >
    > My question is this: how can I have some kind of server side script
    > (and probably client side javascript) on the pages that contain this
    > datagrid control (there are quite a few...), so that it can detect if
    > the grid is in edit mode and will confirm if the user wants to save
    > the changes made, before clicking
    > away to another link on the page that is not the 'save' link? This
    > will be very similar to the windows forms 'Exit without saving?'
    > popup, so if
    > users make changes to a record and forget to push the save/update
    > button, then decide to click somewhere else on the page, it will tell
    > them..."hey
    > you need to save!"
    >
    > If anyone has any ideas on how to implement this, please let me
    > know. I appreciate all of your help. Below is a rough pseudo code of
    > my datagrid control within an aspx file. Most of the logic for the
    > datagrid control is in the assembly for the custom control itself
    > (i.e. itemcreated, itemdatabound, init, load, edit/delete command)
    >
    > Regards,
    > Thiago
    > Web Developer
    >
    > <Grid:CustomDG id=MyDG runat="server"
    > ShowHeader="True"
    > AutoGenerateColumns="False"
    > DBTable = "tblMyTable"
    > DataKeyField = "MyKeyField"
    > GridLines="None"
    > Cellpadding="5"
    > width="800"
    > BackColor="FloralWhite"
    > BorderColor="Navy"
    > BorderStyle="solid"
    > BorderWidth="1px"
    > CssClass="panel"
    > AllowPaging="True"
    > PageSize="1"
    >
    > OnUpdateCommand="MyDG_Update"
    >
    > HeaderStyle-BackColor="lightgrey"
    > HeaderStyle-Font-Name="Verdana"
    > HeaderStyle-Font-Bold="True"
    > HeaderStyle-HorizontalAlign="Right"
    >
    > FooterStyle-BackColor="lightgrey"
    > FooterStyle-Font-Name="Verdana"
    > FooterStyle-Font-Bold="True" >
    > <Columns>
    > <asp:TemplateColumn>
    > <ItemTemplate>
    > <TABLE cellSpacing="0" cellPadding="0" align="center" border="1"
    > bordercolor="#696969" width="100%">
    > <tr bgColor="LightSteelBlue">
    > <td class="tblHead">Some Information:</td>
    > </tr>
    > <tr><td>
    > <TABLE class="setText" id="tblReason" cellSpacing="1"
    > cellPadding="4" width="100%" align="center" border="0">
    > <tr>
    > <td class="label">Field Name: </td>
    > <td>
    > <asp:Label id="lblMyLabel"
    > CssClass="txtIn"
    > Text='<%# DataBinder.Eval(Container, "DataItem.MyFieldName") %>'
    > Runat="server"/>
    > </td>
    > </tr>
    > </TABLE>
    > </td></tr>
    > </TABLE>
    > </ItemTemplate>
    > <EditItemTemplate>
    > <TABLE cellSpacing="0" cellPadding="0" align="center" border="1"
    > bordercolor="#696969" width="100%">
    > <tr bgColor="LightSteelBlue">
    > <td class="tblHead">Provider Information:</td>
    > </tr>
    > <tr><td>
    > <TABLE class="setText" id="tblReason" cellSpacing="3" cellPadding="3"
    > width="100%" align="center" border="0">
    > <tr>
    > <td class="label">Field Name: </td>
    > <td>
    > <asp:TextBox id="lblMyLabel"
    > CssClass="txtIn"
    > Text='<%# DataBinder.Eval(Container, "DataItem.MyFieldName") %>'
    > </td></tr>
    > </TABLE>
    > </EditItemTemplate>
    > </asp:TemplateColumn>
    > </Columns>
    > </Grid:CustomDG>
    > ...
    >
    > I do the databinding, and all other required logic, in the custom
    > control's source code (assembly).
     
    Eric, Feb 6, 2004
    #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. tafs7
    Replies:
    0
    Views:
    525
    tafs7
    Dec 29, 2003
  2. UJ
    Replies:
    9
    Views:
    5,864
    mallik
    Jul 22, 2005
  3. tafs7
    Replies:
    0
    Views:
    215
    tafs7
    Dec 29, 2003
  4. tafs7
    Replies:
    2
    Views:
    235
  5. tafs7
    Replies:
    2
    Views:
    180
Loading...

Share This Page