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. Passing input parameter to external js file function

Passing input parameter to external js file function

Scheduled Pinned Locked Moved ASP.NET
javascripttutorial
4 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.
  • A Offline
    A Offline
    anandhakrishnan
    wrote on last edited by
    #1

    Hi, I have written the following function in external JScript.js file. function validateParameter(textBoxId) { var paramname = document.getElementById(textBoxId); alert(paramname); } Text="Save Comments" OnClientClick="javascript: return validateParameter('<%=txtParam.ClientID %>');"> But during the runtime it showing the alert message as null. How to pass the input parameter to the function which in external javascript file. Tnks in advance!

    T L A 3 Replies Last reply
    0
    • A anandhakrishnan

      Hi, I have written the following function in external JScript.js file. function validateParameter(textBoxId) { var paramname = document.getElementById(textBoxId); alert(paramname); } Text="Save Comments" OnClientClick="javascript: return validateParameter('<%=txtParam.ClientID %>');"> But during the runtime it showing the alert message as null. How to pass the input parameter to the function which in external javascript file. Tnks in advance!

      T Offline
      T Offline
      ToddHileHoffer
      wrote on last edited by
      #2

      Can you try adding the javascript in your code behind? OnPageLoad do btnSaveCom.attributes.add("onclick", return validateParameter('" + txtParam.ClientID + "');"); If you need to. You can create a second javascript method right in your aspx page. for example callValidator(clientId) { var paramname = document.getElementById(clientId); validateParameterWithParamInsteadOfId(paramname); } I didn't get any requirements for the signature

      1 Reply Last reply
      0
      • A anandhakrishnan

        Hi, I have written the following function in external JScript.js file. function validateParameter(textBoxId) { var paramname = document.getElementById(textBoxId); alert(paramname); } Text="Save Comments" OnClientClick="javascript: return validateParameter('<%=txtParam.ClientID %>');"> But during the runtime it showing the alert message as null. How to pass the input parameter to the function which in external javascript file. Tnks in advance!

        L Offline
        L Offline
        led mike
        wrote on last edited by
        #3

        As Todd suggests use code behind

        btnSaveCom.OnClientClick = string.Format("validateParameter('{0}')", txtParam.ClientID);

        led mike

        1 Reply Last reply
        0
        • A anandhakrishnan

          Hi, I have written the following function in external JScript.js file. function validateParameter(textBoxId) { var paramname = document.getElementById(textBoxId); alert(paramname); } Text="Save Comments" OnClientClick="javascript: return validateParameter('<%=txtParam.ClientID %>');"> But during the runtime it showing the alert message as null. How to pass the input parameter to the function which in external javascript file. Tnks in advance!

          A Offline
          A Offline
          Abhishek Sur
          wrote on last edited by
          #4

          use btnSaveCom.Attributes.Add("OnClick","javascript:return xx('" + btnxx.ClientID + "');"); in the code area. But you cant alert the parname as its an object. write alert(paramname).value instead.:rose:

          Abhishek Sur

          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