locked
JavaScript RRS feed

  • Question

  • I am developing a website in which I have used HTML button control of type submit. How can I connect to database(SQL) and authenticate the user based on the information stored in the database. Since I have used HTML control it required Javascript this is the point of struggle for me.


    Any suggestions


    Regards,
    Ajeet Nigam 
    • Moved by Harry Zhu Friday, May 15, 2009 2:15 AM (From:JScript for the .NET Framework)
    Friday, May 8, 2009 6:23 AM

Answers

  • Hi,

    Use both the events like
    <input id="Submit1" runat="server" type="submit" onclick="Sub_onclick()"  onserverclick="Button1_Click" value="submit" />

    onclick for javascript(client side) and onserverclick for server side.

    AnupDG
    • Marked as answer by Ajeet Nigam Thursday, May 21, 2009 6:10 AM
    Monday, May 11, 2009 6:00 AM
  • Hi there

         It seems to me that you are using a fluid layout with the divs, while this is cool it can be a pain. The best thing to do with afluid layout is the still atleast have min and max width/height. also remember to clear your floated dis so you don't get that messy underflow at times.

    • Marked as answer by Ajeet Nigam Thursday, May 21, 2009 6:10 AM
    Wednesday, May 13, 2009 11:15 AM

All replies

  • Hi,

    Are you using .aspx page or a html page.

    If aspx, you can use---


    In aspx:
     <input id="Submit1" runat="server" type="submit" onserverclick="Button1_Click" value="submit" />

    In cs:

     protected void Button1_Click(object sender, EventArgs e)
        {

        }

     
    If HTML page:

    Use XMLHttpRequest object.
    for reference use
    http://www.15seconds.com/Issue/020606.htm
    http://www.mikesdotnetting.com/Article.aspx?ArticleID=40

    Regards
    AnupDG
    Friday, May 8, 2009 9:30 AM
  • Thanks Anup I will try and get back to you with the result........and with more queries



    Thank you

    Regards
    Ajeet Nigam
    Saturday, May 9, 2009 2:03 PM
  • Greetings Anup,
                            I have tried your suggestion but still I am encountering the issue it goes like:
    I have design the login using table and html control. The login table which is embedded in the web page have the following fields: user id, Password and a button. I have used Javascript to check if the fields(user id and password) is blank or not when user click on button the code goes like:

    function Sub_onclick()
    {
    var myForm=document.form1;
    if(myform.UserID.value=="")
    {
    alert("User ID can not be blank");
    myform.UserID.focus();
    }
    else if(myform.Password.value=="")
        {
    alert("Password can not be blank");
    myform.Password.focus();
    }
    }
    else
    {
    }
    the problen is button control is only catching the onclick event when I write onserverclick the above code dose not work. Please guide me.


    Thanking You

    Ajeet Nigam
    Monday, May 11, 2009 5:12 AM
  • Hi,

    Use both the events like
    <input id="Submit1" runat="server" type="submit" onclick="Sub_onclick()"  onserverclick="Button1_Click" value="submit" />

    onclick for javascript(client side) and onserverclick for server side.

    AnupDG
    • Marked as answer by Ajeet Nigam Thursday, May 21, 2009 6:10 AM
    Monday, May 11, 2009 6:00 AM
  • Hi,
         I am designing a website in which I have used tables and html controls to design a login page. The issue I am encountering is when I minimize the browser the login shift towards right on the page and when I maximises the browser it comes to its original position. I have used div(panel design) to design the the page.

    How should I retify the issue.

    Your suggestion will be appriciated

    Thanking You

    Ajeet Nigam 
    • Proposed as answer by jaikudo Wednesday, May 13, 2009 11:10 AM
    Wednesday, May 13, 2009 8:39 AM
  • Hi there

         It seems to me that you are using a fluid layout with the divs, while this is cool it can be a pain. The best thing to do with afluid layout is the still atleast have min and max width/height. also remember to clear your floated dis so you don't get that messy underflow at times.

    • Marked as answer by Ajeet Nigam Thursday, May 21, 2009 6:10 AM
    Wednesday, May 13, 2009 11:15 AM
  • Hi,

    For the
    questions relating to asp.net ,please post to: http://forums.asp.net/.

    Thanks,
    Harry


    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
    Welcome to the All-In-One Code Framework! If you have any feedback, please tell us.
    Friday, May 15, 2009 2:14 AM
  • Hi,
         I have used both the events one for the javascript and the other for the server side as mentioned onclick="Sub_onclick()"  onserverclick="Button1_Click" value="submit" /> I have created a new database and a table that will hold the user login credentials (eg user id and password) and in the login page I have used asp controls. The problem is when I am using
    <authentication mode=forms />
    <authorization>
    <deny user="?"/>
    <authorization>  

    in the web.config the code does not work but when I use authentication mode=windows the code works perfectly.  have not used the asp build in login controls but designed my own login control using tables, asp textbox control and asp buton control.

    please guide me how to use forms authentication so that code works correctly.


    Thanking You
    Ajeet Nigam     
    Tuesday, May 19, 2009 1:16 PM