Saturday, 15 September 2012

javascript - Create and download an text file in a client-server system -



javascript - Create and download an text file in a client-server system -

in ms dynamics crm create on own ribbon button text file contact attributes. file save or download client machine, user can work it.

how can this? i'm going crazy while testing lot of different ways.

create javascript string , seek downlaod info uri. dosen't work

var content = "test";

window.open("data:text/octet-stream," + encodeuricomponent(content));

try silverlight (localy create file) remote dosen't work

next seek fill/create javascript *.aspx file on server , create text file. don't know if working or can otherwise?

please give me hints solve problem.

ok solved it.

in crm integrated javascript code open aspx site.

function createvcf() { var entityname = xrm.page.data.entity.getentityname(); var guid = xrm.page.data.entity.getid(); window.open("http://xxxxx/vcfexport.aspx?guid="+guid+ "&name="+entityname ); }

and there create vcard , give download

public partial class vcfexport : system.web.ui.page { protected void page_load(object sender, eventargs e) { //authenticate using credentials of iis clientcredentials credentials = new clientcredentials(); uri organizationuri = new uri("http://server/org/xrmservices/2011/organization.svc"); uri homerealmuri = null; organizationserviceproxy serviceproxy = new organizationserviceproxy(organizationuri, homerealmuri, credentials, null); iorganizationservice service = (iorganizationservice)serviceproxy; string guidstring = request.querystring["guid"]; string entityname = request.querystring["name"]; if (guidstring != null && entityname != null && guidstring != "" && entityname != "") { columnset columnset = new columnset(true); guid guid = new guid(guidstring); // retrieve contact dataset entity contactentity = service.retrieve(entityname, guid, columnset); // create new vcard vcard vcard = new vcard(); vcard.firstname = contactentity.getattributevalue<string>("firstname"); vcard.lastname = contactentity.getattributevalue<string>("lastname"); //...... string filename = vcard.lastname + " " + vcard.firstname + ".vcf"; response.contenttype = "text/x-vcard"; response.appendheader("content-disposition", "attachment; filename=" + filename); // give download window response.write(vcard.tostring()); response.end(); } else { lblerror.text = "es ist ein fehler aufgetreten. entityname oder guid sind falsch"; } }

javascript asp.net silverlight dynamics-crm-2011

No comments:

Post a Comment