Solved

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

Posted on 2006-11-16
4
323 Views
Last Modified: 2011-10-03
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
Comment
Question by:balone351
  • 2
  • 2
4 Comments
 
LVL 11

Expert Comment

by:ethoths
ID: 17956387
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
 

Author Comment

by:balone351
ID: 17986596
sorry, not up with java, using asp.net2?
0
 
LVL 11

Accepted Solution

by:
ethoths earned 500 total points
ID: 17986644
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
 

Author Comment

by:balone351
ID: 17987032
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

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
This tutorial demonstrates a quick way of adding group price to multiple Magento products.

744 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now