server side code

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • mvmashraf
    New Member
    • Oct 2007
    • 36

    #1

    server side code

    In javascript I need assign value to the asp.net hidden field

    I used like this
    function set values()
    {
    document.getEle mentById('hf_Sa veChanges').val ue = "1";
    }

    But it shows error

    Any suggetion would be appreciatable
  • kenobewan
    Recognized Expert Specialist
    • Dec 2006
    • 4871

    #2
    Wouldn't be due to the fact that it is hidden? Is this server side code written to the client?

    Comment

    • Saad Alam
      New Member
      • Oct 2007
      • 27

      #3
      Try this Im sure this will work,

      function set values()
      {
      document.getEle mentById('<%= hf_SaveChanges. ClientID%>').va lue = "1";
      }

      If you still get the error than plz specify what error are you getting.

      Comment

      • mzmishra
        Recognized Expert Contributor
        • Aug 2007
        • 390

        #4
        I did the same like below
        function GetCurrentFormC ontrolName(orig inalname)
        {
        var ctrllength=wind ow.document.all .length;
        for(var count=0; count<ctrllengt h; count++)
        {
        var controlname=win dow.document.al l.item(count).i d;
        var startindex = controlname.len gth - originalname.le ngth;
        if(startindex < controlname.len gth && controlname.ind exOf(originalna me, startindex)!=-1)
        {
        return controlname;
        }
        }
        }

        function set()
        {
        var controlname = GetCurrentFormC ontrolName("hf_ SaveChanges");
        var control = window.document .all.item(contr olname);

        control.value=" 1";
        }

        Comment

        Working...