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. ASP.NET+Javascript [modified]

ASP.NET+Javascript [modified]

Scheduled Pinned Locked Moved ASP.NET
csharpjavajavascriptasp-netdata-structures
4 Posts 3 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.
  • B Offline
    B Offline
    Bajrang Singh
    wrote on last edited by
    #1

    Hi All, I am trying Javascript for Validation of a new User Registration. I want to know whether user already exits or not. I m trying to check it on Submit button. I want to do it through Javascript. I confused while mixing the code of javascript and ASp.net. I created a string array of all user already exist. now I want to check it in java script for new user's name. I m new to javascript. Please guideme thanks in advance,. Asp: protected void Page_Load(object sender, EventArgs e) { con = new OleDbConnection(); con.ConnectionString = conString; con.Open(); cmdSelect = new OleDbCommand("select * from User_Information", con); da = new OleDbDataAdapter("select * from User_Information",con); ds = new DataSet(); da.Fill(ds); ArrayPassword = new string[100]; ArrayNames = new string[100]; for (i= 0; i < ds.Tables[0].Rows.Count;i++ ) { ArrayNames[i]=(ds.Tables[0].Rows[i].ItemArray[0].ToString()); ArrayPassword[i]=(ds.Tables[0].Rows[i].ItemArray[1].ToString()); } int j = ArrayNames.Count; string arr = ArrayNames; //Response.Write(ArrayNames[j - 1].ToString()); } Javascript: function Validate() { for (var i=0;i; var j; var arrayNames=<%=ArrayNames%> ; // ERROR COMES IN THIS LINE....ANY CLUE for(j=0;j -- modified at 7:54 Tuesday 19th June, 2007 -- modified at 8:29 Tuesday 19th June, 2007 Bajrang Singh Using .net 2.0 (VS2005)

    R C 2 Replies Last reply
    0
    • B Bajrang Singh

      Hi All, I am trying Javascript for Validation of a new User Registration. I want to know whether user already exits or not. I m trying to check it on Submit button. I want to do it through Javascript. I confused while mixing the code of javascript and ASp.net. I created a string array of all user already exist. now I want to check it in java script for new user's name. I m new to javascript. Please guideme thanks in advance,. Asp: protected void Page_Load(object sender, EventArgs e) { con = new OleDbConnection(); con.ConnectionString = conString; con.Open(); cmdSelect = new OleDbCommand("select * from User_Information", con); da = new OleDbDataAdapter("select * from User_Information",con); ds = new DataSet(); da.Fill(ds); ArrayPassword = new string[100]; ArrayNames = new string[100]; for (i= 0; i < ds.Tables[0].Rows.Count;i++ ) { ArrayNames[i]=(ds.Tables[0].Rows[i].ItemArray[0].ToString()); ArrayPassword[i]=(ds.Tables[0].Rows[i].ItemArray[1].ToString()); } int j = ArrayNames.Count; string arr = ArrayNames; //Response.Write(ArrayNames[j - 1].ToString()); } Javascript: function Validate() { for (var i=0;i; var j; var arrayNames=<%=ArrayNames%> ; // ERROR COMES IN THIS LINE....ANY CLUE for(j=0;j -- modified at 7:54 Tuesday 19th June, 2007 -- modified at 8:29 Tuesday 19th June, 2007 Bajrang Singh Using .net 2.0 (VS2005)

      R Offline
      R Offline
      RepliCrux
      wrote on last edited by
      #2

      Personally I think that it will be a bad idea to use javascript for validations such as user and password. If you really want to use flashy stuff for validation, use Ajax.

      1 Reply Last reply
      0
      • B Bajrang Singh

        Hi All, I am trying Javascript for Validation of a new User Registration. I want to know whether user already exits or not. I m trying to check it on Submit button. I want to do it through Javascript. I confused while mixing the code of javascript and ASp.net. I created a string array of all user already exist. now I want to check it in java script for new user's name. I m new to javascript. Please guideme thanks in advance,. Asp: protected void Page_Load(object sender, EventArgs e) { con = new OleDbConnection(); con.ConnectionString = conString; con.Open(); cmdSelect = new OleDbCommand("select * from User_Information", con); da = new OleDbDataAdapter("select * from User_Information",con); ds = new DataSet(); da.Fill(ds); ArrayPassword = new string[100]; ArrayNames = new string[100]; for (i= 0; i < ds.Tables[0].Rows.Count;i++ ) { ArrayNames[i]=(ds.Tables[0].Rows[i].ItemArray[0].ToString()); ArrayPassword[i]=(ds.Tables[0].Rows[i].ItemArray[1].ToString()); } int j = ArrayNames.Count; string arr = ArrayNames; //Response.Write(ArrayNames[j - 1].ToString()); } Javascript: function Validate() { for (var i=0;i; var j; var arrayNames=<%=ArrayNames%> ; // ERROR COMES IN THIS LINE....ANY CLUE for(j=0;j -- modified at 7:54 Tuesday 19th June, 2007 -- modified at 8:29 Tuesday 19th June, 2007 Bajrang Singh Using .net 2.0 (VS2005)

        C Offline
        C Offline
        Christian Graus
        wrote on last edited by
        #3

        This is a disaster. You should never assume that ANYTHING on the client side is what you expect, anything you do in client side, should be validated on the server. It's trivial to hack your page, and make it accept any password you like. It's also trivial to view the source, and see all the username/passwords in your system. Even allowing SQL that returns all the user details is a mess and should be avoided. Please tell me you're just playing around, and no-one will ever rely on this code for security ?

        Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

        B 1 Reply Last reply
        0
        • C Christian Graus

          This is a disaster. You should never assume that ANYTHING on the client side is what you expect, anything you do in client side, should be validated on the server. It's trivial to hack your page, and make it accept any password you like. It's also trivial to view the source, and see all the username/passwords in your system. Even allowing SQL that returns all the user details is a mess and should be avoided. Please tell me you're just playing around, and no-one will ever rely on this code for security ?

          Christian Graus - Microsoft MVP - C++ Metal Musings - Rex and my new metal blog "I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )

          B Offline
          B Offline
          Bajrang Singh
          wrote on last edited by
          #4

          Thanks Christian Graus for advice. I was just playing around. I will be highly thankful to you if you can tell me what the Mistake is there in following line var arrayNames=<%=ArrayNames%> ; // ERROR COMES IN THIS LINE ,,, Thanks again.

          Bajrang Singh Using .net 2.0 (VS2005)

          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