最近到一个公司做asp.net,里面些基本全部用ObjectDataSource来处理,我很不喜欢,特讨厌这个东西,还是喜欢把数据操作单独分开,我觉得那样好调试.
还有发现在vs2005,asp.net里用vb写可以用MsgBox这个方法,不过用c#没有.
咋办了...
尽可能放自己的分.....

解决方案 »

  1.   

    to 最近到一个公司做asp.net,里面些基本全部用ObjectDataSource来处理,我很不喜欢,特讨厌这个东西,还是喜欢把数据操作单独分开,我觉得那样好调试.有时候公司的限制是比较烦人的,公司选取比较好的模式,有利于培养员工,和提高效率。
    但是有时候公司以利益优先,往往看不到这一点。
    to 还有发现在vs2005,asp.net里用vb写可以用MsgBox这个方法,不过用c#没有.use js "Alert" method
      

  2.   

    private void Button1_Click(object sender, System.EventArgs e)
    {
    MsgBox(this,"abc");
    }
    static public void MsgBox(Page page,string msg)
    {
    page.RegisterStartupScript("alert","<script language=javascript>alert('"+msg.Replace("'","\\'")+"');</script>");
    }
      

  3.   

    我的意思不是你们的alter啊噢,搞清楚了.不妨大家建个vb项目看看噢.MsgBox的用法就想在winform一样噢
      

  4.   

    VB的MsgBox也是用的MessageBox.Show
    看一下MsgBox反编译的C#代码:[HostProtection(SecurityAction.LinkDemand, Resources=0x80)]
    public static MsgBoxResult MsgBox(object Prompt, [Optional] MsgBoxStyle Buttons /* = 0 */, [Optional] object Title /* = null */)
    {
          IWin32Window window1 = null;
          string text1 = null;
          string text2;
          IVbHost host1 = HostServices.VBHost;
          if (host1 != null)
          {
                window1 = host1.GetParentWindow();
          }
          if ((((Buttons & ((MsgBoxStyle) 15)) > MsgBoxStyle.RetryCancel) || ((Buttons & ((MsgBoxStyle) 240)) > MsgBoxStyle.Information)) || ((Buttons & ((MsgBoxStyle) 0xf00)) > MsgBoxStyle.DefaultButton3))
          {
                Buttons = MsgBoxStyle.OkOnly;
          }
          try
          {
                if (Prompt != null)
                {
                      text1 = (string) Conversions.ChangeType(Prompt, typeof(string));
                }
          }
          catch (StackOverflowException exception1)
          {
                throw exception1;
          }
          catch (OutOfMemoryException exception2)
          {
                throw exception2;
          }
          catch (ThreadAbortException exception3)
          {
                throw exception3;
          }
          catch (Exception)
          {
                throw new ArgumentException(Utils.GetResourceString("Argument_InvalidValueType2", new string[] { "Prompt", "String" }));
          }
          try
          {
                if (Title == null)
                {
                      if (host1 == null)
                      {
                            text2 = Interaction.GetTitleFromAssembly(Assembly.GetCallingAssembly());
                      }
                      else
                      {
                            text2 = host1.GetWindowTitle();
                      }
                }
                else
                {
                      text2 = Conversions.ToString(Title);
                }
          }
          catch (StackOverflowException exception4)
          {
                throw exception4;
          }
          catch (OutOfMemoryException exception5)
          {
                throw exception5;
          }
          catch (ThreadAbortException exception6)
          {
                throw exception6;
          }
          catch (Exception)
          {
                throw new ArgumentException(Utils.GetResourceString("Argument_InvalidValueType2", new string[] { "Title", "String" }));
          }
          return (MsgBoxResult) MessageBox.Show(window1, text1, text2, ((MessageBoxButtons) Buttons) & ((MessageBoxButtons) 15), ((MessageBoxIcon) Buttons) & ((MessageBoxIcon) 240), ((MessageBoxDefaultButton) Buttons) & ((MessageBoxDefaultButton) 0xf00), ((MessageBoxOptions) Buttons) & ((MessageBoxOptions) (-4096)));
    }
      

  5.   

    用ObjectDataSource,你应该参考一下那些Starter Kit,例如VS2005自带Personal Web Site那个。人家也是DAL到BLL在到页面,然后ObjectDataSource就是沟通BLL和页面上数据控件的桥梁,为此提供便利。详细的便利就是,你在ObjectDataSource中制定对应BLL的SELECT/INSERT/UPDATE/DELETE方法,然后就可以用别的数据控件去帮定ObjectDataSource了,之后数据控件上的操作就能够自动操作到BLL。
      

  6.   

    我的意思是说在web里面,可以用到Msgbox这个函数.而不要应用winform,大家建个web(vs2005+vb.net)项目看看
      

  7.   

    自己写个
    public class MessageBox
    {
    public static void Show(System.Web.UI.Page page,string msg)
    {

    page.Response.Write("<script language=javascript>");
    page.Response.Write("alert('");
    page.Response.Write(msg);
    page.Response.Write("');</script>");
    } public static void Show(System.Web.UI.UserControl page,string msg)
    {
    page.Response.Write("<script language=javascript>");
    page.Response.Write("alert('");
    page.Response.Write(msg);
    page.Response.Write("');;history.back();</script>");
    }
    public MessageBox()
    {
    }
    }
      

  8.   

    我觉得VB的MsgBox也是用的MessageBox.Show
    还是不好!毕竟那是桌面开发的一些东西!
    建议用javascript:
                                /// <summary>
    /// 弹出JavaScript小窗口
    /// </summary>
    /// <param name="js">窗口信息</param>
    public static void Alert(string message)
    {
    message = StringUtil.DeleteUnVisibleChar(message);
    string js=@"<Script language='JavaScript'>
                        alert('"+ message +"');</Script>";
    HttpContext.Current.Response.Write(js);
    }
      

  9.   

    asp.net里用vb写可以用MsgBox这个方法,不过用c#没有.很奇怪楼主的分怎么混来的
      

  10.   

    你自己看看噢.在2003里面是没有的噢.
    你们的函数能在asp.net里这样用么?
      If MsgBox("OK", MsgBoxStyle.YesNoCancel, "haha") = MsgBoxResult.Yes Then
                MsgBox(My.User.Name)
      End If还没有明白我的意思,我这个msgbox是后台写的代码,不是前台写的.怀疑是把vbscrpit转过来的
    是什么自己建个东西看看.不要乱说.
      

  11.   

    我不是说你们那些常用的用Response输出到客户端.那些谁不知道.
    有点怀疑是vb.net项目组故意加个小花招.
      

  12.   

    我觉的ObjectDataSource还是挺不错的啊,可能对高手来说这东西用着不顺手,可是对于一些中小型项目来说还是很有用的,能少写不少代码啊。只要数据库设计好了,拿上来一绑定就可以了,做数据录入模块儿比原来快多了
      

  13.   

    今天搞了一天这个ObjectDataSource,头多大了.
      

  14.   

    Response.Write("<script>window.alert('"+stringMessage+"')</script>")
      

  15.   

    我知道你这个语句,我意是在说明vb.net里面有那个msgbox函数,感觉与在做winform里面一样的.
    是不是有点孔已子啊
      

  16.   

    private void Button1_Click(object sender, System.EventArgs e)
    {
    MsgBox(this,"abc");
    }
    static public void MsgBox(Page page,string msg)
    {
    page.RegisterStartupScript("alert","<script language=javascript>alert('"+msg.Replace("'","\\'")+"');</script>");
    }
      

  17.   

    适应...╭═══════════════════╮
    ║ 免费的源码、工具网站,欢迎大家访问!║
    ║ http://www.j2soft.cn/        ║
    ╰═══════════════════╯
      

  18.   

    问题1:
    不喜欢可以不用,个人问题;问题2:在C#中可以这样写:
    先引用using Microsoft.VisualBasic;
    然后:
     if (Interaction.MsgBox("OK", MsgBoxStyle.YesNoCancel, "haha") == MsgBoxResult.Yes)
           {
               Interaction.MsgBox(Environment.UserName, MsgBoxStyle.OkOnly, "test");
           } if (Interaction.MsgBox("OK", MsgBoxStyle.YesNoCancel, "haha") == MsgBoxResult.Yes)
           {
               Interaction.MsgBox(Environment.UserName, MsgBoxStyle.OkOnly, "test");
           }
      

  19.   

    [HostProtection(SecurityAction.LinkDemand, Resources=0x80)]
    public static MsgBoxResult MsgBox(object Prompt, [Optional] MsgBoxStyle Buttons /* = 0 */, [Optional] object Title /* = null */)
    {
          IWin32Window window1 = null;
          string text1 = null;
          string text2;
          IVbHost host1 = HostServices.VBHost;
          if (host1 != null)
          {
                window1 = host1.GetParentWindow();
          }
          if ((((Buttons & ((MsgBoxStyle) 15)) > MsgBoxStyle.RetryCancel) || ((Buttons & ((MsgBoxStyle) 240)) > MsgBoxStyle.Information)) || ((Buttons & ((MsgBoxStyle) 0xf00)) > MsgBoxStyle.DefaultButton3))
          {
                Buttons = MsgBoxStyle.OkOnly;
          }
          try
          {
                if (Prompt != null)
                {
                      text1 = (string) Conversions.ChangeType(Prompt, typeof(string));
                }
          }
          catch (StackOverflowException exception1)
          {
                throw exception1;
          }
          catch (OutOfMemoryException exception2)
          {
                throw exception2;
          }
          catch (ThreadAbortException exception3)
          {
                throw exception3;
          }
          catch (Exception)
          {
                throw new ArgumentException(Utils.GetResourceString("Argument_InvalidValueType2", new string[] { "Prompt", "String" }));
          }
          try
          {
                if (Title == null)
                {
                      if (host1 == null)
                      {
                            text2 = Interaction.GetTitleFromAssembly(Assembly.GetCallingAssembly());
                      }
                      else
                      {
                            text2 = host1.GetWindowTitle();
                      }
                }
                else
                {
                      text2 = Conversions.ToString(Title);
                }
          }
          catch (StackOverflowException exception4)
          {
                throw exception4;
          }
          catch (OutOfMemoryException exception5)
          {
                throw exception5;
          }
          catch (ThreadAbortException exception6)
          {
                throw exception6;
          }
          catch (Exception)
          {
                throw new ArgumentException(Utils.GetResourceString("Argument_InvalidValueType2", new string[] { "Title", "String" }));
          }
          return (MsgBoxResult) MessageBox.Show(window1, text1, text2, ((MessageBoxButtons) Buttons) & ((MessageBoxButtons) 15), ((MessageBoxIcon) Buttons) & ((MessageBoxIcon) 240), ((MessageBoxDefaultButton) Buttons) & ((MessageBoxDefaultButton) 0xf00), ((MessageBoxOptions) Buttons) & ((MessageBoxOptions) (-4096)));
    }
      

  20.   

    晕,asp.net在C#真的不能用那种有YesNoCancel的,vb.net可以吗
      

  21.   

    刚才去建了个vb+asp.net的去试了一下
    现在报告结果,没弄过什么是UserInteractive 模式结果如下:
    在应用程序未以 UserInteractive 模式运行的情况下显示有模式对话框或窗体是无效的操作。请指定 ServiceNotification 或 DefaultDesktopOnly 样式,以显示服务应用程序发出的通知。 
    说明: 执行当前 Web 请求期间,出现未处理的异常。请检查堆栈跟踪信息,以了解有关该错误以及代码中导致错误的出处的详细信息。 异常详细信息: System.InvalidOperationException: 在应用程序未以 UserInteractive 模式运行的情况下显示有模式对话框或窗体是无效的操作。请指定 ServiceNotification 或 DefaultDesktopOnly 样式,以显示服务应用程序发出的通知。源错误: 
    行 26:     End Sub
    行 27:     Private Sub aa()
    行 28:         If MsgBox("OK", MsgBoxStyle.YesNoCancel, "haha") = MsgBoxResult.Yes Then
    行 29:             MsgBox("aa")
    行 30:         End If
     
      

  22.   

    用XSD作为DAL,然后写代码实现BLL,在页面上用ObjectDataSource操作BLL,而页面上其它数据控件都由ObjectDataSource获取数据,这应该是MS推荐的、最RAD的做法了。
      

  23.   

    jf
    我没用05,就没试,不过我想vb可以,C#应该也行.通常都是JS写的