广州爱启迪技术有限公司
  首页 软件购买 软件下载 软件帮助 网站建设 技术支持 技术文章  
 
 
QQ:6966254、841278774
Email:6966254@qq.com
wuhuacong@163.com
 
爱启迪技术文章分类

1)技术文章
提供最为经典实用的技术资料,拓宽你的知识面,辅助你的开发工作,提高工作效率。

2)面试求职
介绍IT人士在面试求职的注意知识以及提供一些面试试题,让你眼观六路,耳听八方。

3)其他文章
介绍生活、娱乐、哲理的一些相关文章,充实你的生活,娱乐你的大脑。

我们的服务
了解我们


Visual WebGUI 应用技巧

Visual WebGUI - 如何处理MessageBox的DialogResult值

这个挺简单。但还是需要两步:

1、设置MessageBox.Show()。

MessageBox.Show("Save the changes?", "Message", MessageBoxButtons.YesNo, MessageBoxIcon.Question, new EventHandler(SaveMessageHandler));

2、你也看到第一步,有个EventHandler。这就是第二步了:

private void SaveMessageHandler(object sender, EventArgs e)
{
     if (((Form)sender).DialogResult == DialogResult.Yes)
      {
           Save();
      }
      this.Close();
 }

你看到的前面的两个步骤,就完成处理MessageBox的DialogResult了。Open-mouthed

其实也是由官网得到的消息,Tongue out。地址是:How to use message boxes

 

Visual WebGUI - 如何将Dialog的结果传回主窗体

在用WebGUI开发过程中,发现无法得到弹出窗体(Dialog)要返回的值,因此就到处搜索了一番,结果在WebGUI的网站找到了这个视频 How to return parameters from dialogs? 。里面分有几个步骤:

1、先在Dialog中设置一个Boolean变量 IsCompleted ,其实最好用公开的属性(Public Property)啦!然后,根据需要返回的结果,来设置其他的属性。如:

        #region Properties
        private bool isCompleted = false;
        public bool IsCompleted
        {
            get
            {
                return isCompleted;
            }
            set
            {
                isCompleted = value;
            }
        }

        private Guid productId = System.Guid.Empty;
        public Guid ProductId
        {
            get
            {
                return productId;
            }
            set
            {
                productId = value;
            }
        }
        #endregion

2、然后,在准备关闭Dialog返回主窗时,在按钮事件或者其他事件中设置属性的值。如:

this.IsCompleted = true;
this.ProductId = new Guid(txtProductId.Text);
this.Close();

3、接着,挺重要的,就是在弹出Dialog时,设置关闭它后的事件。就是Closed事件。如:

        FrmFindProd objFindProd = new FrmFindProd();
        objFindProd.Closed += new EventHandler(objFindProd_Closed);
        objFindProd.ShowDialog(); 
        void objFindProd_Closed(object sender, EventArgs e)
        {
            FrmFindProd objFindProd = sender as FrmFindProd;
            if (objFindProd.IsCompleted)
            {
                this.ProductId = objFindProd.ProductId;
            }
        }

就这样。在关闭Dialog后,将会获得从Dialod返回的结果。Smile

 

Visual WebGUI Report - 导出到PDF

在Visual WebGUI处理Report的导出问题,跟在WebForm中的做法真不一样,还真头疼了一阵。但是在Visual WebGUI的论坛里找到了解决方法。一样是用 HttpResponse 来解决,但是Visual WebGUI中需要有它自己的方法才行,不然,最后导出只是在页面上显示的一大堆乱码而已。

       这是论坛中介绍解决方法的链接:Visual WebGUI Forum

       下面来段摘抄(位于上面的链接的最后一个Post)吧,Open-mouthed。这个例子用的Visual Studio自带的Report控件rdlc,大家将就着看吧。Tongue out

        The form which tries to open the pdf file must be a gizmox gateway control ("IGatewayControl") so it will handle the file writing response disconected from WebGUI‘s main response. In order to solve your problem, implement the Gizmox.WebGUI.Common.Interfaces.IGatewayControl interface as follow:

 

public class Form1 : Form, IGatewayControl
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            Link.Open(new GatewayReference(this, "open"));
        }

        #region IGatewayControl Members

        public IGatewayHandler GetGatewayHandler(IContext objContext, string strAction)
        {
            LocalReport local = new LocalReport();
            local.ReportPath = Context.Server.MapPath("~/Report1.rdlc");

            DataSet1 dataSet = new DataSet1();
            DataSet1TableAdapters.Tabla1TableAdapter Adapter = new WebGUIApplication1.DataSet1TableAdapters.Tabla1TableAdapter();
            Adapter.Fill(dataSet.Tabla1);
            ReportDataSource dataSource = new ReportDataSource("DataSet1_Tabla1", dataSet.Tabla1);
            local.DataSources.Add(dataSource);

            string reportType = "PDF";
            string mimeType = "application/pdf";
            string encoding;
            string fileNameExtension;

            //The DeviceInfo settings should be changed based on the reportType
            //http://msdn2.microsoft.com/en-us/library/ms155397.aspx

            string deviceInfo =
            "" +
            "  PDF" +
            "  8.5in" +
            "  11in" +
            "  0.5in" +
            "  1in" +
            "  1in" +
            "  0.5in" +
            "";

            Warning[] warnings;
            string[] streams;
            byte[] renderedBytes;

            //Render the report
            renderedBytes = local.Render(reportType, deviceInfo, out mimeType, out encoding, out fileNameExtension, out streams, out warnings);

            //Clear the response stream and write the bytes to the outputstream
            //Set content-disposition to "attachment" so that user is prompted to take an action
            //on the file (open or save)

            HttpResponse objResponse = this.Context.HttpContext.Response;

            objResponse.Clear();
            objResponse.ClearHeaders();
            objResponse.ContentType = mimeType;
            objResponse.AddHeader("content-disposition", "attachment; filename=foo." + fileNameExtension);
            objResponse.BinaryWrite(renderedBytes);
            objResponse.Flush();
            objResponse.End();

          
            return null;
        }

        #endregion
    }    

2008-8-5 14:28:12


 
 
 
 
 友情链接: | | |
  
广州爱启迪技术有限公司 Ganzhou iqidi Technology Co., Ltd.
Copyright © 2007-2027 iqidi Corporation, All Rights Reserved
粤ICP备07054877号