Problem
The ID of controls present in the content page will be changed if master page is used during rendering.
For your textbox
<asp:TextBox ID="txt_TotalFees" runat="server" Width="200px" onblur="SurName()" Enabled="false">
The id
txt_TotalFees
will become something like
'ctl00_ContentPlaceHolder1_txt_TotalFees'
(not exact).
You can see this by viewing the source of the webpage in the browser.
Solutions
1.
ClientID, if you are writing this in content aspx page (not your case).
var x = document.getElementById("<%= txt_TotalFees.ClientID %>");
It will not work in External js file.
2.
Declare a global js variable in the aspx file and set it to the ClientID value. Now in the external is file you can use getElementById on this var.
Refer -
How to get client id at external javascript file[
^]
2.
ClientIDMode.Static (
try this one)
You can use this one. Just add this attribute to the textbox like below.
<asp:TextBox ID="txt_TotalFees" runat="server" Width="200px" onblur="SurName()" Enabled="false" ClientIDMode="Static">
So, after rendering in browser the ID will be the same as
txt_TotalFees
.
Then, the below line in External js will work.
var x = document.getElementById("txt_TotalFees");
To know more about the ClientIDMode refer -
ASP.NET 4.0 : Manipulate ClientID using ClientIDMode[
^]
Try this solution and let me know.
Thanks...