CRM2011彈出asp.net模態視窗關閉的問題

來源:互聯網
上載者:User

標籤:des   style   blog   io   color   os   ar   java   for   

<%@ 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 = 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=‘" + ownerid + "‘;window.opener = \"\"; window.open(\"\", \"_self\"); window.close();</script>");                //Response.Write("<script>window.returnValue=‘" + ownerid + "‘;window.close();</script>");            }           }        protected void btnCancel_Click(object sender, EventArgs e)        {            //Response.Write("<script>window.returnValue=‘1‘;</script>");            Response.Write("<script>window.returnValue=‘" + ownerid + "‘;window.opener = \"\"; window.open(\"\", \"_self\"); window.close();</script>");        }    }}


這是模態視窗的代碼,通過Response.Write始終關閉不了模態視窗,具體原因不明覺厲,希望大家各抒己見探討探討,請各位高手多多指教。。。。。。

CRM2011彈出asp.net模態視窗關閉的問題

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.