[Webinar] Streamline your web hosting managementRegister Today

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 335
  • Last Modified:

detect Control Changed (Get Dirty?) for any control on an asp.net 2.0 page

Just looking for a simple way to detect that any control on a web page has been changed, or even clicked into, so I can clear a message etc when the next operation is beginning. i.e the page says thank you for saving, then user wants to start a new record, I want to detect this and clear or change the message.

Thanks
0
balone351
Asked:
balone351
  • 2
  • 2
1 Solution
 
ethothsCommented:
It's all client side javascript...

<html>
      <head>
            <script language="javascript">
                  function setMessage()
                  {
                         document.getElementById("Message").innerText="You are entering new data!!!!"
                  }
            </script>
      </head>
      <body>
            <input type="text" onclick="javascript:setMessage()">
            <div id="Message">Message</div>
      </body>
</html>
0
 
balone351Author Commented:
sorry, not up with java, using asp.net2?
0
 
ethothsCommented:
If you want it client side it'll have to be JavaSCRIPT. The previous code actually works. Just cut and paste it into a page and you'll be able to see how it works. If you want to know when a user "or even clicked into" a control like a text box then you'll HAVE to do this.

You can do some of the other things using postbacks but that's a lot of work and a huge roundtrip just to change a message.

Remember, there is nothing wrong with using javascript on an asp.net page. Javascript is the only cross brower programming technology that works on the client. In fact ASP.NET renders a lot of javascript to the page automatically in certain circumstances. If you're going to be an ASP.Net developer then you'll have to at least have an appreciation of javascript.



0
 
balone351Author Commented:
Thanks for pushing me ethoths, I am keen to get it right, and would love to get a handle on javascript, just so much to learn already moving to .net!! Really appreciate your time

I've tried to add your code to the page, but keep tripping over. below is the page i have that it needs to be added to, if you could help me with this i can run with it in other areas. I am using a master page, would that make a difference? the page has a content place holder in it which changes the html a bit.

Sorry, on a steep learning curve here, i thought this one was easy

Here's the page:

<%@ Page Language="VB" MasterPageFile="~/MasterPage.master" AutoEventWireup="false" CodeFile="Booking.aspx.vb" Inherits="Home" title="Clickmow Bookings" %>

<%@ Register Assembly="GMDatePicker" Namespace="GrayMatterSoft" TagPrefix="cc1" %>

<asp:Content ID="Content1" ContentPlaceHolderID="ContentPlaceHolder2" Runat="Server">
   
    <span >
        Please fill in the following to order any services you require<br />
        and we will contact you as soon as possible.
        <br /><br />
    </span>
   
    <div>
        <table style="text-align: right;">
            <tr>
                <td style="text-align: right;">
                    <asp:Label ID="Label16" runat="server">Preferred Date:</asp:Label>
                </td>
                <td style="text-align: left;">
                    <cc1:GMDatePicker ID="GMDatePicker1" runat="server" CalendarFont-Names="Arial" InitialText="Select a Date">
                            <CalendarDayStyle Font-Size="9pt" />
                            <CalendarTodayDayStyle BorderWidth="1" BorderColor="darkred" Font-Bold="true" />
                            <CalendarOtherMonthDayStyle BackColor="whitesmoke" />
                            <CalendarTitleStyle BackColor="#E0E0E0" Font-Names="Arial" Font-Size="9pt" />
                      </cc1:GMDatePicker><br />
                </td>
            </tr>
            <tr>
                <td style="text-align: right;">
                    <asp:Label ID="lblWork" runat="server">What would you like done?</asp:Label>
                </td>
                <td style="text-align: left;">
                    <asp:TextBox skinID="TextBoxMultiLine" ID="txtWork" runat="server" TextMode="MultiLine"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td style="text-align: right;">
                    <asp:Label ID="lblDiscountCode" runat="server">Discount Code:</asp:Label>
                </td>
                <td style="text-align: left;">
                    <asp:TextBox ID="txtDiscountCode" runat="server"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td style="text-align: right;">
                    <asp:Label ID="lblFirstName" runat="server">First Name:</asp:Label>
                </td>
                <td style="text-align: left;">
                    <asp:TextBox ID="txtFirstName" runat="server"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td style="text-align: right;">
                    <asp:Label ID="lblLastName" runat="server">Last Name:</asp:Label>
                </td>
                <td style="text-align: left;">
                    <asp:TextBox ID="txtLastName" runat="server"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td style="text-align: right;">
                    <asp:Label ID="lblHomePhone" runat="server">Home Phone:</asp:Label>
                </td>
                <td style="text-align: left;">
                    <asp:TextBox ID="txtHomePhone" runat="server"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td style="text-align: right;">
                    <asp:Label ID="lblMobile" runat="server">Mobile:</asp:Label>
                </td>
                <td style="text-align: left;">
                    <asp:TextBox ID="txtMobile" runat="server"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td style="text-align: right;">
                    <asp:Label ID="lblEmail" runat="server">Email:</asp:Label>
                </td>
                <td style="text-align: left;">
                    <asp:TextBox ID="txtEmail" runat="server"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td style="text-align: right;">
                    <asp:Label ID="lblStreetNumber" runat="server">Street Number:</asp:Label>
                </td>
                <td style="text-align: left;">
                    <asp:TextBox ID="txtStreetNumber" runat="server"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td style="text-align: right;">
                    <asp:Label ID="lblStreetName" runat="server">StreetName:</asp:Label>
                </td>
                <td style="text-align: left;">
                    <asp:TextBox ID="txtStreetName" runat="server"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td style="text-align: right;">
                    <asp:Label ID="lblSuburb" runat="server">Suburb:</asp:Label>
                </td>
                <td style="text-align: left;">
                    <asp:TextBox ID="txtSuburb" runat="server"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td style="text-align: right;">
                    <asp:Label ID="lblPostCode" runat="server">PostCode:</asp:Label>
                </td>
                <td style="text-align: left;">
                    <asp:TextBox ID="txtPostCode" runat="server"></asp:TextBox>
                </td>
            </tr>
            <tr>
                <td style="text-align: right;">
                    <asp:Label ID="lblExtraDetails" runat="server">Extra Details:</asp:Label>
                </td>
                <td style="text-align: left;">
                    <asp:TextBox skinID="TextBoxMultiLine" ID="txtExtraDetails" runat="server" TextMode="MultiLine"></asp:TextBox>
                </td>
            </tr>
        </table>
        <asp:Label ID="lblThanks" runat="server">Details Saved, Thank You</asp:Label>
        <br />
        <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Submit" Width="156px" /><br />
        <br />
        <span >
        *Enter Your Discount Code Number to receive 20% off your first Booking.
        <br />
        Discount does not apply to cost of materials.<br />
        </span>
    </div>        
   
</asp:Content>

0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now