Click here to Skip to main content
15,885,944 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
This is my code(addSchoolOffice.aspx.cs):
C#
protected void btnAdd_Click(object sender, EventArgs e)
    {
        if (txtSchoolOffice.Text == "" || txtSODesc.Text == "")
        {
            ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('Fill all the necessary information.');", true);
        }
        else
        {
            blSchool.addOff(txtSchoolOffice.Text,
                txtSODesc.Text);
            Response.Redirect("~/MaintenanceOFF.aspx");
        }
    }

This is at my addSchoolOffice.aspx
C#
<asp:Button ID="btnAdd" class="buttonsMainteUN"  runat="server" Text="Add" 
            ToolTip="Add a school/office" onclick="btnAdd_Click"/>
Posted
Updated 12-Aug-13 19:37pm
v4
Comments
Thanks7872 13-Aug-13 1:41am    
Show the definition of txtSchoolOffice.Text and txtSODesc.Text.

Further,i don't know why you are checking it at server side.

instead of

ClientScript.RegisterStartupScript(this.GetType(), "myalert", "alert('Fill all the necessary information.');", true);


try this:

Page.ClientScript.RegisterClientScriptBlock(typeof(Page), "Alert", "alert('Fill all the necessary information.')", true);


or debug your control using breakpoint.
 
Share this answer
 
v2
Comments
timJosh 13-Aug-13 4:13am    
tnx to your response but it still doesn't work. What else can I do?
timJosh 13-Aug-13 4:31am    
I am using a watermark for my textbox and it is the one being captured instead of a blank textbox, I still want the watermark though here's the code for the txtbox:


<asp:TextBox ID="txtSchoolOffice" runat="server"
Width="200px" text="" onfocus="if (this.value == 'Enter school/office name') this.value = '';" onblur="if (this.value == '') this.value = 'Enter school/office name';" value="Enter school/office name" style="color:Gray; text-align:left;" xmlns:asp="#unknown">
macmacmacmac 14-Aug-13 1:22am    
i copied your textbox codes, and i transferred the textbox value to a messagebox. it works fine. just make sure that you put /> at the end of your code. it doesn't have an ending tag
Use FilteredTextBoxExtender instead

Sample
XML
<asp:TextBox ID="txtRentalPeriodPoint" runat="server" CssClass="fromborder" Width="75"
                                                    MaxLength="3"></asp:TextBox>
                                                <ajaxToolkit:FilteredTextBoxExtender ID="FilteredTextBoxExtender6" runat="server"
                                                    TargetControlID="txtRentalPeriodPoint" FilterType="Numbers" Enabled="True" />
                                                (Hrs) </span>
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900