Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. calling client side script under page load event

calling client side script under page load event

Scheduled Pinned Locked Moved ASP.NET
sysadmincsharpdatabasetoolshelp
3 Posts 2 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • P Offline
    P Offline
    peter rankel
    wrote on last edited by
    #1

    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

    L 1 Reply Last reply
    0
    • P peter rankel

      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

      L Offline
      L Offline
      l0kke
      wrote on last edited by
      #2

      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

      P 1 Reply Last reply
      0
      • L l0kke

        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

        P Offline
        P Offline
        peter rankel
        wrote on last edited by
        #3

        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

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups