javascript in usercontrol ascx file

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • atiger
    New Member
    • Sep 2008
    • 3

    javascript in usercontrol ascx file

    i want to add a javascript validation in a ascx page. i have a checkbox and a textbox in this page, if user clicks the submit button without checking a box ,nor entering anything in the textbox, a alert message should be pop up.
    I also have master page in the whole system.
    Can anyone help me please?

    Thank you soooo much.
  • nateraaaa
    Recognized Expert Contributor
    • May 2007
    • 664

    #2
    I would create a .js file with your javascript code then reference the .js file in the head of each aspx page you want the javascript to run on.

    <HEAD>
    <script language="javas cript" src="JavaScript File.js"></script>
    </HEAD>

    If you want the javascript code to be available to all of the aspx pages just reference the .js file in your Master page.

    See the following thread if you want to add the .js file to your master page.


    Nathan

    Comment

    • nateraaaa
      Recognized Expert Contributor
      • May 2007
      • 664

      #3
      I would create a .js file with your javascript code then reference the .js file in the head of each aspx page you want the javascript to run on.

      <HEAD>
      <script language="javas cript" src="JavaScript File.js"></script>
      </HEAD>

      If you want the javascript code to be available to all of the aspx pages just reference the .js file in your Master page.

      See the following thread if you want to add the .js file to your master page.
      http://bytes.com/forum/thread574518.ht ml

      Nathan

      Comment

      • Frinavale
        Recognized Expert Expert
        • Oct 2006
        • 9749

        #4
        All the information you need on controls that use JavaScript for client side validation and any other .NET controls can be found in the MSDN Library. This resource should get you pointed in the right direction....th ere are multiple articles on controls like the RequiredFieldVa lidator which will do client side validation for you. Be sure to look into how you can group controls into one validation group so that you don't have too many validation controls doing the same thing. I recommend bookmarking the MSDN Library and using it as your primary resource when developing in .NET.

        Please take the time to research the problem before you post your question. The experts here are more than willing to help you with a specific problem but you have to do your part to learn the basics. Please take the time to read over the posting guidelines specifically the section on Before you post your question.

        -Frinny

        Comment

        Working...