i.e u are calling the script function while loading page, so u r calling the script function before loading the textboxes. that y its giving the object error.
hence,
add script tag in header tag of aspx page
<head runat="sever">
<SCRIPT Language='JavaScript' src='JScript.js'></SCRIPT>
then u can call this
Button1.Attributes.Add("OnClick", "RegainFocus()");</head>