ASP.NET中的对话框结果框 [英] Dialog result box in ASP.NET

查看:71
本文介绍了ASP.NET中的对话框结果框的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我可以在Asp.net中使用此代码,我的意思是我可以在Asp.net中使用对话框结果和消息框吗?



我尝试过:



Can I use this Code as it is in Asp.net , I mean Can I Use Dialog Result and Message box in Asp.net??

What I have tried:

DialogResult Dialog = MessageBox.Show(" The File is Already exist , Do you want to replace it?", Name, MessageBoxButtons.YesNo);
                if (Dialog == DialogResult.Yes)
                {

                    SqlCommand cmdupdate = new SqlCommand("update Attcehments set Data=@Data,Semester='" + semester + "' where AttchName='" + Name + "'and CourseNum='" + course_number + "'", connection);
                    cmdupdate.Parameters.Add("@Data", SqlDbType.Binary).Value = bytes;
                    cmdupdate.ExecuteNonQuery();
                    lblMessage.Text = "Updated Successfully";
                }
                else { lblMessage.Text = "Not updated!!"; }//end else

            }//end if
            else
            {
                //insert the file into database

                string strQuery = "insert into Attcehments(AttchName, CourseNum,Semester, Data,Priority)  values ('" + Name + "','" + course_number + "','" + semester + "', @Data,'" + priority + "')";
                SqlCommand cmdinsert = new SqlCommand(strQuery, connection);
                cmdinsert.Parameters.Add("@Data", SqlDbType.Binary).Value = bytes;
                cmdinsert.ExecuteNonQuery();
                lblMessage.Text = "File Uploaded Successfully";



            }

推荐答案

你不能使用 MessageBox结果在Asp.net中,它将由 confirm()函数替换[ ^ ]在javascript中,前提是您必须处理您的业务逻辑并了解如何 Asp页面生命周期 [ ^ ]工作



加价

You cannot use MessageBox result in Asp.net, it shall be replaced by confirm() function [^] in javascript, provided you will have to take care of your business logic and knowing how Asp page life cycle[^] works

Mark up
<asp:Button ID="Button1" OnClientClick="funCheck()" runat="server" Text="Button" OnClick="Button1_Click" />
    <asp:HiddenField ID="HiddenField1" runat="server" />



Javascript


Javascript

function funCheck() {
          var flag = confirm('The File is Already exist , Do you want to replace it?');
          var hdnfld = document.getElementById('<%= HiddenField1.ClientID %>');
          hdnfld.value = flag ? '1' : '0';
      }



代码落后


Code behind

protected void Button1_Click(object sender, EventArgs e)
       {
           if (HiddenField1.Value == "1")
           {
               // do some action
           }
           else
           {
               // do other action
           }
       }


aspx:

aspx:
<asp:LinkButton ID="ModalDummy" runat="server" />
<ajaxToolkit:ModalPopupExtender ID="ModalDummy_ModalPopupExtender" runat="server" BehaviorID="ModalDummy_ModalPopupExtender" TargetControlID="ModalDummy" PopupControlID="PanelPopup">
</ajaxToolkit:ModalPopupExtender>
<asp:Panel ID="PanelPopup" runat="server" DefaultButton="ButtonContactSend">
    your popup
</asp:Panel>







代码落后




code behind

ModalDummy_ModalPopupExtender.Show();


您不能在ASP.NET应用程序中使用MessageBox。当然,它适用于您的机器。将其部署到实际的Web服务器,您的代码将坐在那里等待输入,这将永远不会发生,因为MessageBox将显示在SERVER上的桌面上,而不是客户端。即使您登录到服务器控制台,您仍然不会看到MessageBox。它将显示在登录用户看不到的桌面上。



您的代码需要彻底检修才能删除对MessageBox的所有这些引用和DialogResult。它们在ASP.NET应用程序中没有任何意义。
You cannot use MessageBox in an ASP.NET app. Sure, it works on your machine. Deploy this to an actual web server and your code will sit there waiting for input that will never happen as the MessageBox will show up on a desktop on the SERVER, NOT THE CLIENT. Even if you log into the server console, you still won't see the MessageBox. It'll show up on a desktop that is not visible to the logged in user.

You're code needs to be completely overhauled to remove all these references to MessageBox and DialogResult. They have no meaning in an ASP.NET app.


这篇关于ASP.NET中的对话框结果框的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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