I have one web page on masterPage i have 2 links which redirects user to another page...
For example:
Link 1:Customer Detail-this page contain some textbox to save data into the database such as customer id, customer name, customer address,customer contact..

Link 2:Employee Details-this page contain some textbox to save data into the database such as Employee id, Employee name, Employee address,Employee contact..


Suppose user is currently on Page 2 that is Link 2.... And He have entered Some text in all 4 textBox... and forgets to save data... and directly click on Pafe 1 that is Link 1...
Then He should get error message saying "the data is not saved.. this will take u to another page and your entered data will be lost.."

MasterPage code:

<%@ Master Language="C#" AutoEventWireup="true" CodeFile="MasterPage.master.cs" Inherits="MasterPage" %>

<!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>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
    <script>
    function confirm()
{
if (confirm ==true)

else

return false;

}
</script>

        &nbsp;<table border="0" cellpadding="0" cellspacing="0" style="width: 100%; height: 100%">
            <tr>
                <td colspan="2" style="height: 200px">
                    &nbsp;</td>
            </tr>
            <tr>
                <td style="width: 200px">
                    <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Button" />
                    <asp:Button ID="Button2" runat="server" OnClick="Button2_Click" Text="Button" />
                   </td>
                <td>
                    <asp:ContentPlaceHolder ID="ContentPlaceHolder1" runat="server">
                    </asp:ContentPlaceHolder>
                </td>
            </tr>
            <tr>
                <td colspan="2" style="height: 200px">
                </td>
            </tr>
        </table>
    </div>
    </form>
</body>
</html>

And on click on those link have this code...

protected void Button1_Click(object sender, EventArgs e)
    {
        Button1.Attributes.Add("onclick", "return confirm('Are you sure you proceed?');");
        
    }

But i want to show message box only when the textbox are not blank....
PLS HELP....

Please help.....

Set up Roles.

Redirect users according to their roles.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.