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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Web Development
  3. ASP.NET
  4. how to get value from web.config file in javascript function

how to get value from web.config file in javascript function

Scheduled Pinned Locked Moved ASP.NET
javascripthelptutorialquestion
12 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.
  • _ _AK_

    One work around can be to assign the value in a hidden field and then use it in your javascript function.

    Apurva Kaushal

    D Offline
    D Offline
    deep7
    wrote on last edited by
    #3

    i tried that...i kept it in an asp literal: then in javascript function, var formatString = literalFormat.value; but this throws error saying that "literalFormat.value is undefined"...but on screen u can see the literal value which is coming from web.config file. I tried using textbox also..still same prob... could u tell me why that error message comes?

    _ 1 Reply Last reply
    0
    • D deep7

      i tried that...i kept it in an asp literal: then in javascript function, var formatString = literalFormat.value; but this throws error saying that "literalFormat.value is undefined"...but on screen u can see the literal value which is coming from web.config file. I tried using textbox also..still same prob... could u tell me why that error message comes?

      _ Offline
      _ Offline
      _AK_
      wrote on last edited by
      #4

      Use Hidden field.

      Apurva Kaushal

      D 1 Reply Last reply
      0
      • _ _AK_

        Use Hidden field.

        Apurva Kaushal

        D Offline
        D Offline
        deep7
        wrote on last edited by
        #5

        i did that too... still it says that txthidden is undefined :( wot to do...could u help me out?

        _ J 2 Replies Last reply
        0
        • D deep7

          i did that too... still it says that txthidden is undefined :( wot to do...could u help me out?

          _ Offline
          _ Offline
          _AK_
          wrote on last edited by
          #6

          Try like this: Apurva Kaushal

          D 1 Reply Last reply
          0
          • D deep7

            i did that too... still it says that txthidden is undefined :( wot to do...could u help me out?

            J Offline
            J Offline
            Jay_se
            wrote on last edited by
            #7

            You may try from the code behind also (C#.net) string dateFormat=ConfigurationManager.AppSettings["DisplayDateFormat"]; txthidden.Value=dateFormat;

            deep7 wrote:

            value="<%$ AppSettings : DisplayDateFormat %>"

            Also You may try with single quotes, instead of double quotes.

            Regards, Jay :)

            1 Reply Last reply
            0
            • _ _AK_

              Try like this: Apurva Kaushal

              D Offline
              D Offline
              deep7
              wrote on last edited by
              #8

              hi Apurva, i get the following error: Literal expressions like '<%$ Configuration.ConfigurationSettings.AppSettings["DisplayDateFormat"]%>' are not allowed. Use " /> instead.

              _ 1 Reply Last reply
              0
              • D deep7

                hi Apurva, i get the following error: Literal expressions like '<%$ Configuration.ConfigurationSettings.AppSettings["DisplayDateFormat"]%>' are not allowed. Use " /> instead.

                _ Offline
                _ Offline
                _AK_
                wrote on last edited by
                #9

                Have you put that value part in single quotes if so then remove it and then try.

                Apurva Kaushal

                D 1 Reply Last reply
                0
                • _ _AK_

                  Have you put that value part in single quotes if so then remove it and then try.

                  Apurva Kaushal

                  D Offline
                  D Offline
                  deep7
                  wrote on last edited by
                  #10

                  no i haven't... its: " />

                  _ 1 Reply Last reply
                  0
                  • D deep7

                    no i haven't... its: " />

                    _ Offline
                    _ Offline
                    _AK_
                    wrote on last edited by
                    #11

                    Remove double quotes.

                    deep7 wrote:

                    " />

                    /> Apurva Kaushal

                    1 Reply Last reply
                    0
                    • D deep7

                      Hi, In web.config file under , i have: I have a javascript function: function ValidateForm(strVal) { if(web.config's DisplayDateFormat="MM/dd/yyyy") if (isDate(strVal)==false) { return false } else { //do something } return true } So how to get the DisplayDateFormat from web.config file in my javascript function? Could anyone please help me out here? Thanks, Dee

                      B Offline
                      B Offline
                      Biju Sam
                      wrote on last edited by
                      #12

                      on runtime ie when u take document.getElementById('txtName') the value of txtName will be different, thats why you are getting a undefined error. take viewsource and find out the value of the hidden field first and then give that name. it will be somethinglike ctl00$MainContent$txtDateSearch Biju S

                      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