CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 11 of 11

Hybrid View

  1. #1
    Join Date
    Apr 2005
    Posts
    172

    AJAX and Tables in Database

    Hello All AJAX Gurus,

    I have the following issue:

    I have an AJAX ModalPopUpExtender control which brings up a panel which has a field to enter User Name and Password. The panel also contins an OK and Cancel Buttons.Here is the code for the panel and the ModalPopUpExtender.
    Code:
    <div id="PanelInfo">
    <asp:Button ID="Button1" runat="server" Text="Click here"/>&nbsp;
     <asp:Panel ID="Panel1" runat="server" Style="display: none" CssClass="modalPopup">
        <table>
           <tr>
             <td><asp:Label runat="server" ID="lblUserName" Text="User Name:"/></td>
             <td><asp:TextBox runat="server" ID="txtUserName" /></td>
           </tr> 
           <tr>
             <td><asp:Label runat="server" ID="lblPassword" Text="Password:"/></td>
             <td><asp:TextBox runat="server" ID="txtPassword" /></td>
           </tr>
           <tr>     
             <td><asp:Button ID="OkButton" runat="server" Text="OK" OnClick="OkButton_Click"/></td>
             <td><asp:Button ID="CancelButton" runat="server" Text="Cancel" /></td>
           </tr>
        </table>       
     </asp:Panel>
    
    <cc1:ModalPopupExtender ID="ModalPopupExtender1" runat="server"
                TargetControlID="Button1"
                PopupControlID="Panel1" 
                BackgroundCssClass="modalBackground" 
                OkControlID="OkButton"
                CancelControlID="CancelButton" 
                DropShadow="true"/>
    
    </div>
    and in my .cs file I have

    Code:
    
    protected void Page_Load(object sender, EventArgs e)
        {
            ModalPopupExtender1.Show(); //show the dialog box in which trhe user needs to enter their user name and password
         }

    I want to take the information entered by the user and use it to query a Database table.


    I know how to do all that in a regular environment but the problem I am having with AJAX controls is that the program execution never gets to the OK button's click Event and I partially understand that this can be becausee the page never reloads and since the CLick event occurs after the Load event, the click event never happens. So I don't know where to place my code to access the DataBase and query the table.

    Does anyone know how to handle the above scenario?

    Thanks Very much in advance

    Susan

  2. #2
    Join Date
    May 2002
    Posts
    10,943

    Re: AJAX and Tables in Database

    Any querying of the database would have to be on the server-side script itself. Since a query can be a variable, just take what the user enters and call the query.
    If the post was helpful...Rate it! Remember to use [code] or [php] tags.

  3. #3
    Join Date
    Apr 2005
    Posts
    172

    Re: AJAX and Tables in Database

    Thanks for the quick reply.

    I understand how to do the query but the question is in which event should I place the query code.
    The CLick event of the button never executes since the page never re-loads.

    Thanks

    Susan

  4. #4
    Join Date
    Apr 2005
    Posts
    172

    Re: AJAX and Tables in Database

    In other words the main question here is:

    What server side event happens when I click on the OK button of the ModalPopUpExtender.

    Thanks

  5. #5
    Join Date
    May 2002
    Posts
    10,943

    Re: AJAX and Tables in Database

    The server-side does not have events. Events are triggered on the client-side. Are you using C# as your server-side language? If so, then the query must be put there. If you are using ASP, then the query can be put there.
    If the post was helpful...Rate it! Remember to use [code] or [php] tags.

  6. #6
    Join Date
    Apr 2005
    Posts
    172

    Re: AJAX and Tables in Database

    I am a little confused.
    When you say "there" wher in the program code are you refering?
    In the Button1_Click function, in the Page_Load function?

    Thanks very much for trying to help

    Susan

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured