弹出消息不显示,为什么? [英] Popup message not displaying, Why?

查看:73
本文介绍了弹出消息不显示,为什么?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当用户点击保存按钮时,我会弹出一条消息,但不显示该消息。我的其他代码显示正常,但保存按钮的代码没有。



以下是有效的代码:

  if (Page.IsValid)
{
ScriptManager.RegisterStartupScript( this typeof (页), myscript alert('您已成功提交一般和注册资料的电子部分。请将您签名的资料连同所有必需的附件发送到SACSCOC,Attn:Profiles,1866 Southern Lane,Decatur,Ga 30033。'); location.href ='WelcomeMenu.aspx'; true );
}





以下代码不起作用:

  if (Page.IsValid)
{
SqlConnection con2 = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings [ HotConnectionString]。ConnectionString);
con2.Open();
SqlCommand level = new SqlCommand( select accessLevel,Table99中的User_ID,其中User_ID = @INST_ID AND accessLevel = @accessLevel,con2);
level.Parameters.Add( new SqlParameter( INST_ID,TextBoxINST_ID.Text));
level.Parameters.Add( new SqlParameter( accessLevel,TextBoxaccessLevel.Text));

SqlDataReader reader = level.ExecuteReader();
DataTable dt1 = new DataTable();
dt1.Load(读者);

foreach (DataRow dr1 in dt1.Rows)
{
int returnedLevel = Convert.ToInt32(dr1 [ 0 ]。ToString());
int accessLevel = Convert.ToInt32(dr1 [ 1 ]。ToString());
会话[ accessLevel] = accessLevel;

if (returnedLevel == 1
{

ScriptManager.RegisterStartupScript( this typeof (页面), myscript 警告('您已成功提交同类群组。如果您有其他同类群组,请点击毕业率链接以输入另一个群组'); location.href ='WelcomeMenu.aspx';);
}
else if (returnedLevel == 2
{

ScriptManager.RegisterStartupScript( this typeof (页面), myscript alert('您已成功提交同类群组。如果您有其他同类群组,请点击毕业率链接以输入另一个群组');位置。 href ='WelcomeMenu.aspx'; true );
}
else if (returnedLevel == 3
{

ScriptManager.RegisterStartupScript( this typeof (页面), myscript alert('您已成功提交同类群组。如果您有其他同类群组,请点击毕业率链接以输入另一个群组');位置。 href ='WelcomeMenu.aspx'; true );
}
else if (returnedLevel == 11
{

ScriptManager.RegisterStartupScript( this typeof (页面), myscript alert('您已成功提交同类群组。如果您有其他同类群组,请点击毕业率链接以输入另一个群组');位置。 href ='WelcomeMenu.aspx'; true );
}
else if (returnedLevel == 21
{

ScriptManager.RegisterStartupScript( this typeof (页面), myscript alert('您已成功提交同类群组。如果您有其他同类群组,请点击毕业率链接以输入另一个群组');位置。 href ='WelcomeMenu.aspx'; true );
}
else if (returnedLevel == 31
{

ScriptManager.RegisterStartupScript( this typeof (页面), myscript alert('您已成功提交同类群组。如果您有其他同类群组,请点击毕业率链接以输入另一个群组');位置。 href ='WelcomeMenu.aspx'; true );
}
else if (returnedLevel == 7
{

ScriptManager.RegisterStartupScript( this typeof (页面), myscript alert('您已成功提交同类群组。如果您有其他同类群组,请点击毕业率链接以输入另一个群组');位置。 href ='CEOPage.aspx'; true );
}
}
con2.Close();





我做错了什么?

解决方案

虽然我不确定但是,我注意到你使用了if..else if..else if ..语句。你确定returnedLevel的值总是在1,2,3,11,21,31和&之间。 7?可能是你在这个if..else if..else if ...链的最后一个遗漏了一个简单的else语句。



可能是这样的



  else  {

ScriptManager。 RegisterStartupScript( this typeof (页面), myscript alert('出错了'请再试一次!'); true );
}





如果这不能解决您的问题,请回复。


Tente usar o tipo do script !!



 ScriptManager.RegisterStartupScript(Page,GetType(),Guid .NewGuid()。ToString(),  javascript:alert('您已成功提交同类群组。如果您有附加内容同类群组,请点击毕业率链接以输入另一个同类群组'); window.location.href ='WelcomeMenu.aspx'; true ) ; 


I have a message that pops up when the user clicks the save button but it will not display. My other code displays fine but the one for the save button does not.

Here is the code that works:

if (Page.IsValid)
            {
                ScriptManager.RegisterStartupScript(this, typeof(Page), "myscript", "alert('You have successfully submitted the electronic portion of the General and Enrollment Profile.  Please send your signed Profile along with any required attachments to SACSCOC, Attn: Profiles, 1866 Southern Lane, Decatur, Ga 30033.');location.href='WelcomeMenu.aspx';", true);
            }



Here is the code that does not work:

if (Page.IsValid)
            {
                SqlConnection con2 = new SqlConnection(System.Configuration.ConfigurationManager.ConnectionStrings["HotConnectionString"].ConnectionString);
                con2.Open();
                SqlCommand level = new SqlCommand("select accessLevel, User_ID from Table99 where User_ID = @INST_ID AND accessLevel = @accessLevel", con2);
                level.Parameters.Add(new SqlParameter("INST_ID", TextBoxINST_ID.Text));
                level.Parameters.Add(new SqlParameter("accessLevel", TextBoxaccessLevel.Text));

                SqlDataReader reader = level.ExecuteReader();
                DataTable dt1 = new DataTable();
                dt1.Load(reader);

                foreach (DataRow dr1 in dt1.Rows)
                {
                    int returnedLevel = Convert.ToInt32(dr1[0].ToString());
                    int accessLevel = Convert.ToInt32(dr1[1].ToString());
                    Session["accessLevel"] = accessLevel;

                    if (returnedLevel == 1)
                    {
                        
                        ScriptManager.RegisterStartupScript(this, typeof(Page), "myscript", "alert('You Have Successfully Submitted the Cohort. If you have Additional Cohorts, Please Click on the Graduation Rate Link to Enter another Cohort');location.href='WelcomeMenu.aspx';", true);
                    }
                    else if (returnedLevel == 2)
                    {
                        
                        ScriptManager.RegisterStartupScript(this, typeof(Page), "myscript", "alert('You Have Successfully Submitted the Cohort. If you have Additional Cohorts, Please Click on the Graduation Rate Link to Enter another Cohort');location.href='WelcomeMenu.aspx';", true);
                    }
                    else if (returnedLevel == 3)
                    {
                        
                        ScriptManager.RegisterStartupScript(this, typeof(Page), "myscript", "alert('You Have Successfully Submitted the Cohort. If you have Additional Cohorts, Please Click on the Graduation Rate Link to Enter another Cohort');location.href='WelcomeMenu.aspx';", true);
                    }
                    else if (returnedLevel == 11)
                    {
                        
                        ScriptManager.RegisterStartupScript(this, typeof(Page), "myscript", "alert('You Have Successfully Submitted the Cohort. If you have Additional Cohorts, Please Click on the Graduation Rate Link to Enter another Cohort');location.href='WelcomeMenu.aspx';", true);
                    }
                    else if (returnedLevel == 21)
                    {
                        
                        ScriptManager.RegisterStartupScript(this, typeof(Page), "myscript", "alert('You Have Successfully Submitted the Cohort. If you have Additional Cohorts, Please Click on the Graduation Rate Link to Enter another Cohort');location.href='WelcomeMenu.aspx';", true);
                    }
                    else if (returnedLevel == 31)
                    {
                        
                        ScriptManager.RegisterStartupScript(this, typeof(Page), "myscript", "alert('You Have Successfully Submitted the Cohort. If you have Additional Cohorts, Please Click on the Graduation Rate Link to Enter another Cohort');location.href='WelcomeMenu.aspx';", true);
                    }
                    else if (returnedLevel == 7)
                    {
                        
                        ScriptManager.RegisterStartupScript(this, typeof(Page), "myscript", "alert('You Have Successfully Submitted the Cohort. If you have Additional Cohorts, Please Click on the Graduation Rate Link to Enter another Cohort');location.href='CEOPage.aspx';", true);
                    }
                }
                con2.Close();



What did I do wrong?

解决方案

Although I am not sure but, I noticed that you have used series if..else if..else if.. statements. Are you sure that the value of "returnedLevel" will always be between 1,2,3,11,21,31 & 7? May be you are missing a simple else statement at the last of this "if..else if..else if..." chain.

May be something like

else{
                        
                        ScriptManager.RegisterStartupScript(this, typeof(Page), "myscript", "alert('Something went wrong. Please try again !');", true);
                    }



Please reply if this doesn't solve your problem.


Tente usar o tipo do script!!

ScriptManager.RegisterStartupScript(Page, GetType(), Guid.NewGuid().ToString(), "javascript:alert('You Have Successfully Submitted the Cohort. If you have Additional Cohorts, Please Click on the Graduation Rate Link to Enter another Cohort'); window.location.href='WelcomeMenu.aspx';", true);


这篇关于弹出消息不显示,为什么?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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