Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 2 of 2

Thread: Form Help

  1. #1
    New Coder
    Join Date
    Aug 2011
    Posts
    14
    Thanks
    5
    Thanked 0 Times in 0 Posts

    Form Help

    Hello,
    Firstly thank you for reading this.
    Secondly I hope this is in the correct area.
    I've been tasked with creating a form in ASP.net (that I don't really know) and have been very unsucessful. I've got the form to display as intended, but the actual function of the form is where I'm having difficulty.

    The first thing I'm trying to get to work is an alert to display when a client clicks the "submit" button that reads "Thank you, your information...." then that message would need to have another button on it "OK" that the client would press upon reading the message. here is part of the form I have thus far:

    <div class="cssbutton gBtn a"><asp:Button ID="btnSubmit" runat="server" Text="Submit" OnClientClick="ShowMessage()"></asp:Button></div>

    Now I also have this written further on the page:

    <script type="javascript">
    function ShowMessage()
    {
    document.window.alert("Thank you, your information has been recieved.");
    }
    </script>


    If there is anything anyone can provide to help with this it would be greatly appreciated. If need be I could supply the entire page code, but for purposes of seeing if I'm asking the impossible or something that is way beyond my ability I only pasted the button code and the script I was trying.

    Thank you for your time,

  • #2
    Senior Coder alykins's Avatar
    Join Date
    Apr 2011
    Posts
    1,724
    Thanks
    41
    Thanked 191 Times in 190 Posts
    Code:
    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="WebApplication2._Default" %>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title></title>
    
        <script type="text/javascript">
            function ShowMessage() {
                alert("Thank you, your information has been received.");
            }
        </script>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
            <asp:Button ID="Button1" runat="server" Text="Button" OnClientClick="ShowMessage();" />
        </div>
        </form>
    </body>
    </html>
    you question is more of a javascript question, but that's ok
    worth noting is that you probably shouldn't have it do the alert onclick, you should probably reply and alert if the reply is true....
    eg
    if I fill out form, and then click button, it tells me that you got the info- but what if server is offline and the actual processing never happens (ie you didn't get my data). The alert will pause the post- after you click 'ok' in the alert window, the page will do a postback.

    I code C hash-tag .Net
    Reference: W3C W3CWiki .Net Lib
    Validate: html CSS
    Debug: Chrome FireFox IE

  • Users who have thanked alykins for this post:

    Borgard (05-17-2012)


  •  

    Posting Permissions

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