View Full Version : Form Help

05-16-2012, 08:13 PM
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.");

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,

05-16-2012, 11:01 PM
<%@ 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">

<script type="text/javascript">
function ShowMessage() {
alert("Thank you, your information has been received.");
<form id="form1" runat="server">
<asp:Button ID="Button1" runat="server" Text="Button" OnClientClick="ShowMessage();" />

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....
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.