首页 > 代码库 > CRM2011弹出asp.net模态窗口关闭的问题

CRM2011弹出asp.net模态窗口关闭的问题

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="batchassign.aspx.cs" Inherits="Demo.batchassign" %>

 

using System;using System.Collections.Generic;using System.Linq;using System.Web;using System.Web.UI;using System.Web.UI.WebControls;using Microsoft.Xrm.Sdk.Client;using UploadFiles;using System.ServiceModel.Description;using Microsoft.Xrm.Sdk;using System.Data.SqlClient;using System.Data;namespace Demo{    public partial class batchassign : System.Web.UI.Page    {        private IOrganizationService orgService;        string ownerid = string.Empty;        private static string strConnectionString = null;        protected void Page_Load(object sender, EventArgs e)        {            if (!IsPostBack)            {                orgService = GetCrmService();                BindGridView();            }        }        public void BindGridView()         {            string strOwnerId=Request.QueryString["ownerid"].ToString();            if (!string.IsNullOrEmpty(strOwnerId))            {                Guid OwnerId = new Guid(strOwnerId);                gvInfo.DataSource = GetSettingsByProcedure(orgService, OwnerId);                gvInfo.DataBind();            }        }        protected void gvInfo_RowDataBound(object sender, GridViewRowEventArgs e)        {            try            {                //单选                CheckBox cb = (CheckBox)e.Row.FindControl("chkSelected");                if (cb != null)                    cb.Attributes.Add("onclick", "signcheck(" + cb.ClientID + ")");                //如果是绑定数据行                 if (e.Row.RowType == DataControlRowType.DataRow)                {                    //鼠标经过时,行背景色变                     e.Row.Attributes.Add("onmouseover", "this.style.backgroundColor=‘#E6F5FA‘");                    //鼠标移出时,行背景色变                     e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=‘#FFFFFF‘");                }            }            catch            {                            }        }        private OrganizationServiceProxy GetCrmService()        {            string filePath = MapPath(@"/ISV/Config.txt");            FileConfig config = new FileConfig(filePath);            string crmUrl;            string orgName = config.GetValue("orgName").ToLower();            if (Request.Url.Host.ToLower().StartsWith(orgName, StringComparison.CurrentCultureIgnoreCase))            {                crmUrl = Request.Url.Scheme + "://" + Request.Url.Host + ":" + Request.Url.Port + "/XRMServices/2011/Organization.svc";            }            else            {                crmUrl = Request.Url.Scheme + "://" + Request.Url.Host + ":" + Request.Url.Port + "/" + orgName + "/XRMServices/2011/Organization.svc";            }            ClientCredentials credentials = new ClientCredentials();            credentials.UserName.UserName = config.GetValue("UserName");            credentials.UserName.Password = config.GetValue("Password");            OrganizationServiceProxy crmServiceProxy = new OrganizationServiceProxy(new Uri(crmUrl), null, credentials, null);            return crmServiceProxy;        }        /// <summary>        /// 依据指定的CRM服务,指定的OwnerId,获取销售顾问        /// </summary>        /// <param name="service">指定的CRM服务</param>        /// <param name="entityName">指定的OwnerId</param>        /// <returns>流水号管理类</returns>        public  DataSet GetSettingsByProcedure(IOrganizationService service, Guid OwnerId)        {            DataSet ds = new DataSet();            if (string.IsNullOrEmpty(strConnectionString))            {                SystemConfig config = new SystemConfig(service, "IDOSSales_ReadOnly");                strConnectionString = config.GetValue();            }            using (SqlConnection sqlconn = new SqlConnection(strConnectionString))            {                SqlCommand cmd = new SqlCommand();                cmd.Connection = sqlconn;                cmd.CommandText = "[dbo].[GetSalesConsultant]";                cmd.CommandType = CommandType.StoredProcedure;                sqlconn.Open();                IDataParameter[] parameters = {                                                                                new SqlParameter("@ownerid", SqlDbType.UniqueIdentifier)};                parameters[0].Value =http://www.mamicode.com/ OwnerId;                cmd.Parameters.Add(parameters[0]);                SqlDataAdapter adapter = new SqlDataAdapter(cmd);                adapter.Fill(ds);                sqlconn.Close();            }            return ds;        }        protected void chkSelected_CheckedChanged(object sender, EventArgs e)        {            CheckBox chk = sender as CheckBox;            int index = ((GridViewRow)(chk.NamingContainer)).RowIndex;            if (chk.Checked)            {                ownerid = gvInfo.Rows[index].Cells[3].Text.Trim();            }        }        protected void btnOK_Click(object sender, EventArgs e)        {            if (ownerid != null && ownerid != "")            {                Response.Write("<script>window.returnValue=http://www.mamicode.com/‘" + ownerid + "‘;window.opener = \"\"; window.open(\"\", \"_self\"); window.close();</script>");                //Response.Write("<script>window.returnValue=http://www.mamicode.com/‘" + ownerid + "‘;window.close();</script>");            }           }        protected void btnCancel_Click(object sender, EventArgs e)        {            //Response.Write("<script>window.returnValue=http://www.mamicode.com/‘1‘;</script>");            Response.Write("<script>window.returnValue=http://www.mamicode.com/‘" + ownerid + "‘;window.opener = \"\"; window.open(\"\", \"_self\"); window.close();</script>");        }    }}


这是模态窗口的代码,通过Response.Write始终关闭不了模态窗口,具体原因不明觉厉,希望大家各抒己见探讨探讨,请各位高手多多指教。。。。。。

<style></style><script type="text/javascript">// </script>

CRM2011弹出asp.net模态窗口关闭的问题