Solved

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

Posted on 2006-11-16
4
328 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Ready to get started with anonymous questions?

It's easy! Check out this step-by-step guide for asking an anonymous question on Experts Exchange.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

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…
User art_snob (http://www.experts-exchange.com/M_6114203.html) encountered strange behavior of Android Web browser on his Mobile Web site. It took a while to find the true cause. It happens so, that the Android Web browser (at least up to OS ver. 2.…
In this video, viewers are given an introduction to using the Windows 10 Snipping Tool, how to quickly locate it when it's needed and also how make it always available with a single click of a mouse button, by pinning it to the Desktop Task Bar. Int…
This tutorial will teach you the special effect of super speed similar to the fictional character Wally West aka "The Flash" After Shake : http://www.videocopilot.net/presets/after_shake/ All lightning effects with instructions : http://www.mediaf…

636 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