为什么在我离开txtSchoolOffice和txtSODesc后,我的警报消息没有显示出来。 [英] Why does my alert message doesn't show up after I leave txtSchoolOffice and txtSODesc blanked.

查看:65
本文介绍了为什么在我离开txtSchoolOffice和txtSODesc后,我的警报消息没有显示出来。的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

这是我的代码(addSchoolOffice.aspx.cs):

This is my code(addSchoolOffice.aspx.cs):

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");
        }
    }



这是我的addSchoolOffice.aspx


This is at my addSchoolOffice.aspx

<asp:Button ID="btnAdd" class="buttonsMainteUN"  runat="server" Text="Add" 
            ToolTip="Add a school/office" onclick="btnAdd_Click"/>

推荐答案

而不是



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.


使用FilteredTextBoxExtender代替



样本

Use FilteredTextBoxExtender instead

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


这篇关于为什么在我离开txtSchoolOffice和txtSODesc后,我的警报消息没有显示出来。的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆