0

below are the code in my aspx files, i am trying to call onserverclick of hdnBtn from hdnBtn.click()

the code belows work in Firefox and Chrome but not working in IE, any idea why? thx for helping

  protected void Page_Load(object sender, EventArgs e)
  {
      btnBrowse.Attributes.Add("onclick", file1.ClientID + ".click()");
      file1.Attributes.Add("onchange", hdnBtn.ClientID + ".click()");
  }

input runat="server" id="btnBrowse" type="button" value="..." class="lookupBtn" 
      disabled=true 

input style="visibility:hidden" type="file" runat="server" name="file1" id="file1" 

input style="visibility:hidden" type="button" runat="server" name="hdnBtn" 
      id="hdnBtn" value="" onserverclick="btnLookUpFile_Click"
Shai
  • 25,159
  • 9
  • 44
  • 67

1 Answers1

0

That won't work. you can't call server-side methods from javascript. you could revoke a postback by setting your OnClick to __doPostBack().

Read more regarding __doPostBack here

Community
  • 1
  • 1
Shai
  • 25,159
  • 9
  • 44
  • 67
  • the page rendered give me [input name="ctl00$CPH1$btnBrowse" type="button" id="btnBrowse" value="..." class="lookupBtn" onclick="file1.click()"], [input name="ctl00$CPH1$file1" type="file" id="file1" onchange="test()"],[input onclick="__doPostBack('ctl00$CPH1$hdnBtn','')" name="ctl00$CPH1$hdnBtn" type="button" id="hdnBtn"] – user1237362 Feb 28 '12 at 09:20
  • and when i debug with developers tool in IE, it does goes into the __doPostBack function, but it still doesn't trigger the back end function that i need – user1237362 Feb 28 '12 at 09:22