如何在一个aspx页面中同时使用scriptmanger和ajaxtoolscript manager?

时间:2016-11-14 11:43:13

标签: c# asp.net-4.5

我尝试在aspx页面中使用更新面板以避免按钮单击事件后的页面刷新但在我的代码中我使用了Ajax评级控件,我使用了asp:ToolkitScriptManager但是对于更新面板我添加了scriptmanager它显示错误“只有一个实例一个scriptmanager可以添加到页面“。没有ajaxtoolkit评级不会工作。请任何人可以建议我如何克服这个问题以及如何避免页面刷新后按钮点击。 我的代码: kgis.aspx

        MimeType m = new MimeType();
        HttpPostedFile file = fileupload1.PostedFile;
        byte[] document = new byte[file.ContentLength];
        file.InputStream.Read(document, 0, file.ContentLength);
        string s = m.GetMimeType(document, file.ToString());


        switch (Rating1.CurrentRating)
        {
            case 1:
                remarks = "Poor";
                break;
            case 2:
                remarks = "Average";
                break;
            case 3:
                remarks = "Good";
                break;
            case 4:
                remarks = "Very Good";
                break;
            case 5:
                remarks = "Excellent";
                break;
        }

        switch (Rating2.CurrentRating)
        {
            case 1:
                remarks = "Poor";
                break;
            case 2:
                remarks = "Average";
                break;
            case 3:
                remarks = "Good";
                break;
            case 4:
                remarks = "Very Good";
                break;
            case 5:
                remarks = "Excellent";
                break;
        }
        //string remarks2 = "[unknown]";
        switch (Rating3.CurrentRating)
        {
            case 1:
                remarks = "Poor";
                break;
            case 2:
                remarks = "Average";
                break;
            case 3:
                remarks = "Good";
                break;
            case 4:
                remarks = "Very Good";
                break;
            case 5:
                remarks = "Excellent";
                break;
        }


        if (s.Equals("not valid file"))
        {

           // ScriptManager.RegisterClientScriptBlock(this, this.GetType(), "alertMessage", "alert('file is not valid')", true);
            //Console.WriteLine("The variable is set to true.");
            Label1.Text = "file is not valid";
        }

        else
        {

            using (SqlConnection con = new SqlConnection(connectionString))
            {
                using (SqlCommand cmd = new SqlCommand())
                {



                        con.Open();
                        cmd.CommandText = "insert into FileInformation(usernm,emailID,info,infodesc,portal,portdesc,guirating,ccrating,efrating,feedback,FileName,FileType,FileData) values(@usernm,@emailID,@info,@infodesc,@portal,@portdesc,@guirating,@ccrating,@efrating,@feedback,@Name,@Type,@Data)";
                        cmd.Parameters.AddWithValue("@usernm", usernm);
                        cmd.Parameters.AddWithValue("@emailID", emailID);
                        cmd.Parameters.AddWithValue("@info", radiolist1.SelectedItem.Value);
                        cmd.Parameters.AddWithValue("@infodesc", infodesc.Text);
                        cmd.Parameters.AddWithValue("@portal", RadioButtonList1.SelectedItem.Value);
                        cmd.Parameters.AddWithValue("@portdesc", portdesc.Text);
                        cmd.Parameters.AddWithValue("@guirating", remarks);
                        cmd.Parameters.AddWithValue("@ccrating", remarks);
                        cmd.Parameters.AddWithValue("@efrating", remarks);
                        cmd.Parameters.AddWithValue("@feedback", msg.Text);
                        cmd.Parameters.AddWithValue("@Name", file.FileName);

                        cmd.Parameters.AddWithValue("@Type", s);
                        cmd.Parameters.AddWithValue("@Data", document);


                        cmd.Connection = con;
                        cmd.ExecuteNonQuery();
                        con.Close();
                        // BindGridviewData();

                        ClientScript.RegisterClientScriptBlock(this.GetType(), "alert", "javascript:alert('feedback recieved successfully')", true);



                }
            }
        }

         radiolist1.SelectedIndex = -1;
        infodesc.Text = "";
        RadioButtonList1.SelectedIndex = -1;
        portdesc.Text = "";
        msg.Text = "";
        Rating1.CurrentRating = 0;
        Rating2.CurrentRating = 0;
        Rating3.CurrentRating = 0;
    }

kgis.aspx.cs

protected void btnUpload_Click(object sender,EventArgs e)         {

at()

1 个答案:

答案 0 :(得分:0)

你不能。

证明: http://www.telerik.com/forums/using-both-ajaxtoolkit-scriptmanager-and-telerikscriptmanager

Telerik团队的回答说,

  

“不支持使用两个脚本管理器(RadScriptManager和ToolkitScriptManager),因为页面上只能有一个脚本管理器控件。在这种情况下,使用RadScriptManager并手动注册AjaxToolKit所需的脚本是合适的。” / p>