calling client side script under page load event
-
hi all, i have to execute a query in page load event. Like "select * from tbl where sName= ' " + WindowsUserName + " '" here WindowsUserName is nothing but userName of the windows system. I tried to use server side script to get username but their i am getting system number rather than getting username. But using client side scripting i am getting the windows userName. i failed to use that username in the page load event . my client side scipt is like this sub fncI dim X set X = createobject("WSCRIPT.Network") dim U U=x.UserName end sub help me to use this user name in the page load event thanx in advance..... your peter
-
hi all, i have to execute a query in page load event. Like "select * from tbl where sName= ' " + WindowsUserName + " '" here WindowsUserName is nothing but userName of the windows system. I tried to use server side script to get username but their i am getting system number rather than getting username. But using client side scripting i am getting the windows userName. i failed to use that username in the page load event . my client side scipt is like this sub fncI dim X set X = createobject("WSCRIPT.Network") dim U U=x.UserName end sub help me to use this user name in the page load event thanx in advance..... your peter
If you dont want to use authentication, I have one idea how to use your clientside script, you should register it in (!IsPostBack) block in Page_Load as startup script, and this script should cause postback (domcument.form1.submit() in js, i think). Your script should save username into hidden field, you can read this value in Page_Load after first postback. You cannot read this value when page is created (IsPostBack property is false), because client side script is called on client side after Page_Load and other methods are executed on server side. Btw. can you post a code you use for 'getting system number' ? Maybe I can help you to get user name instead... I hope it helps, if something is not clear, just ask... Pilo
-
If you dont want to use authentication, I have one idea how to use your clientside script, you should register it in (!IsPostBack) block in Page_Load as startup script, and this script should cause postback (domcument.form1.submit() in js, i think). Your script should save username into hidden field, you can read this value in Page_Load after first postback. You cannot read this value when page is created (IsPostBack property is false), because client side script is called on client side after Page_Load and other methods are executed on server side. Btw. can you post a code you use for 'getting system number' ? Maybe I can help you to get user name instead... I hope it helps, if something is not clear, just ask... Pilo
getting system number System.Security.Principal.WindowsPrincipal p = System.Threading.Thread.CurrentPrincipal as System.Security.Principal.WindowsPrincipal; string strName = p.Identity.Name; Response.Write (User.Identity.Name.ToString()); WindowsIdentity user = WindowsIdentity.GetCurrent(); Response.Write(user.Name); your peter