Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. Hi All,

Hi All,

Scheduled Pinned Locked Moved ASP.NET
javascripthtmldatabasedesignquestion
8 Posts 4 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    peacefulmember
    wrote on last edited by
    #1

    I have user control with some standard HTML tags. On one of my HTML button tag I want to perform a javascript validation (a Hello test function for now). I cannot figure out how can I trigger this function from with in my user control on this HTML button tag click event or on usecontrol's click event. Thanks in advance.Partial Class MyUserControl Inherits System.Web.UI.UserControl Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Dim js As StringBuilder = New StringBuilder() js.Append("") js.Append("function Hello() { ") js.Append(" alert ('Hello'); }") js.Append("") If (Not Page.ClientScript.IsStartupScriptRegistered("MyScript")) Then Page.ClientScript.RegisterStartupScript(Me.GetType(), "MyScript", js.ToString()) End If End Sub End Class

    P C N S 4 Replies Last reply
    0
    • P peacefulmember

      I have user control with some standard HTML tags. On one of my HTML button tag I want to perform a javascript validation (a Hello test function for now). I cannot figure out how can I trigger this function from with in my user control on this HTML button tag click event or on usecontrol's click event. Thanks in advance.Partial Class MyUserControl Inherits System.Web.UI.UserControl Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Dim js As StringBuilder = New StringBuilder() js.Append("") js.Append("function Hello() { ") js.Append(" alert ('Hello'); }") js.Append("") If (Not Page.ClientScript.IsStartupScriptRegistered("MyScript")) Then Page.ClientScript.RegisterStartupScript(Me.GetType(), "MyScript", js.ToString()) End If End Sub End Class

      P Offline
      P Offline
      peacefulmember
      wrote on last edited by
      #2

      Sorry, I messed up the subject earlier. But I meant to wish everybody. HI.

      1 Reply Last reply
      0
      • P peacefulmember

        I have user control with some standard HTML tags. On one of my HTML button tag I want to perform a javascript validation (a Hello test function for now). I cannot figure out how can I trigger this function from with in my user control on this HTML button tag click event or on usecontrol's click event. Thanks in advance.Partial Class MyUserControl Inherits System.Web.UI.UserControl Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Dim js As StringBuilder = New StringBuilder() js.Append("") js.Append("function Hello() { ") js.Append(" alert ('Hello'); }") js.Append("") If (Not Page.ClientScript.IsStartupScriptRegistered("MyScript")) Then Page.ClientScript.RegisterStartupScript(Me.GetType(), "MyScript", js.ToString()) End If End Sub End Class

        C Offline
        C Offline
        Christian Graus
        wrote on last edited by
        #3

        The easiest way is to use a custom validator, which can be made to call any function you like.

        Christian Graus - Microsoft MVP - C++ "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

        P 1 Reply Last reply
        0
        • C Christian Graus

          The easiest way is to use a custom validator, which can be made to call any function you like.

          Christian Graus - Microsoft MVP - C++ "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

          P Offline
          P Offline
          peacefulmember
          wrote on last edited by
          #4

          Christian, Custom Validator!! Sorry, I am not too expert with .net. Could you please explain this with an example? Thanks

          1 Reply Last reply
          0
          • P peacefulmember

            I have user control with some standard HTML tags. On one of my HTML button tag I want to perform a javascript validation (a Hello test function for now). I cannot figure out how can I trigger this function from with in my user control on this HTML button tag click event or on usecontrol's click event. Thanks in advance.Partial Class MyUserControl Inherits System.Web.UI.UserControl Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Dim js As StringBuilder = New StringBuilder() js.Append("") js.Append("function Hello() { ") js.Append(" alert ('Hello'); }") js.Append("") If (Not Page.ClientScript.IsStartupScriptRegistered("MyScript")) Then Page.ClientScript.RegisterStartupScript(Me.GetType(), "MyScript", js.ToString()) End If End Sub End Class

            N Offline
            N Offline
            N a v a n e e t h
            wrote on last edited by
            #5

            Since your javascript function is not dynamic, it's better to write in page itself than writing from code behind. Write your javascript function on usercontrol. Assume you have a button tag like

            <input type="button" id="Btn" OnClick="Hello();">

            . This will invoke Hello() method when button is clicked.


            My Website | Ask smart questions

            P 2 Replies Last reply
            0
            • P peacefulmember

              I have user control with some standard HTML tags. On one of my HTML button tag I want to perform a javascript validation (a Hello test function for now). I cannot figure out how can I trigger this function from with in my user control on this HTML button tag click event or on usecontrol's click event. Thanks in advance.Partial Class MyUserControl Inherits System.Web.UI.UserControl Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load Dim js As StringBuilder = New StringBuilder() js.Append("") js.Append("function Hello() { ") js.Append(" alert ('Hello'); }") js.Append("") If (Not Page.ClientScript.IsStartupScriptRegistered("MyScript")) Then Page.ClientScript.RegisterStartupScript(Me.GetType(), "MyScript", js.ToString()) End If End Sub End Class

              S Offline
              S Offline
              S A R I T H
              wrote on last edited by
              #6

              just reply the triggering code u hav...

              Sarith...

              1 Reply Last reply
              0
              • N N a v a n e e t h

                Since your javascript function is not dynamic, it's better to write in page itself than writing from code behind. Write your javascript function on usercontrol. Assume you have a button tag like

                <input type="button" id="Btn" OnClick="Hello();">

                . This will invoke Hello() method when button is clicked.


                My Website | Ask smart questions

                P Offline
                P Offline
                peacefulmember
                wrote on last edited by
                #7

                I do not want to write my javascript in the page itself. Validations are different in the case of different parameters passed to the user control. What do you mean by that javascript function is not dynamic..How can I make it dynamic, if that can lead me to the functionality that I want? So, far I was thinking my javascript is dynamic as I have it in page_load and it will be written to the page after form tag is rendered on the page side. Thanks

                1 Reply Last reply
                0
                • N N a v a n e e t h

                  Since your javascript function is not dynamic, it's better to write in page itself than writing from code behind. Write your javascript function on usercontrol. Assume you have a button tag like

                  <input type="button" id="Btn" OnClick="Hello();">

                  . This will invoke Hello() method when button is clicked.


                  My Website | Ask smart questions

                  P Offline
                  P Offline
                  peacefulmember
                  wrote on last edited by
                  #8

                  Well, I have one more question. Like I mentioned based on user control's parameter value I need to perform different client side validation. I could set parameter of user control (have a property, suggest if there is another better way), but how can I use this property value in Javascript? Thanks for bearing with me.

                  1 Reply Last reply
                  0
                  Reply
                  • Reply as topic
                  Log in to reply
                  • Oldest to Newest
                  • Newest to Oldest
                  • Most Votes


                  • Login

                  • Don't have an account? Register

                  • Login or register to search.
                  • First post
                    Last post
                  0
                  • Categories
                  • Recent
                  • Tags
                  • Popular
                  • World
                  • Users
                  • Groups