CRM2011 Popup ASP window shutdown problem

Source: Internet
Author: User

<%@ page language= "C #" autoeventwireup= "true" codebehind= "Batchassign.aspx.cs" inherits= "Demo.batchassign"%>

usingSystem;usingSystem.Collections.Generic;usingSystem.Linq;usingsystem.web;usingSystem.Web.UI;usingSystem.Web.UI.WebControls;usingMicrosoft.Xrm.Sdk.Client;usingUploadfiles;usingSystem.ServiceModel.Description;usingMICROSOFT.XRM.SDK;usingSystem.Data.SqlClient;usingSystem.Data;namespacedemo{ Public Partial classBatchassign:System.Web.UI.Page {PrivateIorganizationservice Orgservice; stringownerID =string.        Empty; Private Static stringstrConnectionString =NULL; protected voidPage_Load (Objectsender, EventArgs e) {            if(!IsPostBack) {Orgservice=Getcrmservice ();            Bindgridview (); }        }         Public voidBindgridview () {stringstrownerid=request.querystring["ownerID"].            ToString (); if(!string. IsNullOrEmpty (Strownerid)) {Guid ownerID=NewGuid (Strownerid); Gvinfo.datasource=getsettingsbyprocedure (Orgservice, ownerid);            Gvinfo.databind (); }        }        protected voidGvinfo_rowdatabound (Objectsender, GridViewRowEventArgs e) {            Try            {                //RadioCheckBox cb = (checkbox) E.row.findcontrol ("chkselected"); if(CB! =NULL) CB. Attributes.Add ("onclick","Signcheck ("+ CB. ClientID +")"); //If the data row is bound                if(E.row.rowtype = =datacontrolrowtype.datarow) {//when the mouse passes, the row background color changesE.row.attributes.add ("onmouseover","this.style.backgroundcolor= ' #E6F5FA '"); //when the mouse moves out, the row background color changesE.row.attributes.add ("onmouseout","this.style.backgroundcolor= ' #FFFFFF '"); }            }            Catch            {                            }        }        Privateorganizationserviceproxy Getcrmservice () {stringFilePath = MapPath (@"/isv/config.txt"); Fileconfig Config=NewFileconfig (FilePath); stringCrmurl; stringOrgName = 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=Newclientcredentials (); Credentials. Username.username= Config. GetValue ("UserName"); Credentials. Username.password= Config. GetValue ("Password"); Organizationserviceproxy Crmserviceproxy=NewOrganizationserviceproxy (NewUri (Crmurl),NULL, credentials,NULL); returnCrmserviceproxy; }        /// <summary>        ///obtain a sales consultant based on the specified CRM service, the specified ownerid/// </summary>        /// <param name= "service" >The specified CRM service</param>        /// <param name= "EntityName" >the specified ownerid</param>        /// <returns>Serial Number Management class</returns>         PublicDataSet Getsettingsbyprocedure (iorganizationservice service, Guid ownerid) {DataSet DS=NewDataSet (); if(string. IsNullOrEmpty (strConnectionString)) {systemconfig config=NewSystemconfig (Service,"idossales_readonly"); strConnectionString=CONFIG.            GetValue (); }            using(SqlConnection sqlconn =NewSqlConnection (strconnectionstring)) {SqlCommand cmd=NewSqlCommand (); Cmd. Connection=sqlconn; Cmd.commandtext="[dbo]. [Getsalesconsultant]"; Cmd.commandtype=CommandType.StoredProcedure; Sqlconn.                Open (); idataparameter[] Parameters= {                                                                                NewSqlParameter ("@ownerid", Sqldbtype.uniqueidentifier)}; parameters[0]. Value =ownerID; Cmd. Parameters.Add (parameters[0]); SqlDataAdapter Adapter=NewSqlDataAdapter (CMD); Adapter.                Fill (DS); Sqlconn.            Close (); }            returnds; }        protected voidChkselected_checkedchanged (Objectsender, EventArgs e) {CheckBox chk= Sender asCheckBox; intindex =( GridViewRow) (chk. NamingContainer)).            RowIndex; if(CHK. Checked) {ownerID= Gvinfo.rows[index]. cells[3].            Text.trim (); }        }        protected voidBtnok_click (Objectsender, 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 voidBtncancel_click (Objectsender, EventArgs e) {            //Response.Write ("<script>window.returnvalue= ' 1 ';</script>");Response.Write ("<script>window.returnvalue= '"+ ownerID +"'; window.opener = \ "\"; window.open (\ "\", \ "_self\"); Window.close ();</script>"); }    }}


This is the code of the modal window, through the Response.Write always close the modal window, the specific reason is unknown, I hope that we discuss the discussion, please master a lot of advice ...

CRM2011 Popup the ASP. NET modal window closed

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.