1

vcard を作成/ダウンロードするための応答オブジェクトを含むポップアップを生成する Web ページがあります。期待どおりに機能しますが、親ページのフォント サイズが大きくなり、ページを更新しないと元に戻りません。どうすれば修正できますか?

vcardポップアップへの私の呼び出し:

 Response.Write(@"<script language = 'Javascript'>var" +
                        @" win=window.open('vCard.aspx',null,'width=50,height=50," +
                        @"top=100,left=100','true');</script>");

Vcard の作成:

 public static void VCard(HttpResponse response)
    {
        response.Clear();
        response.Charset = "";
        response.ContentType = "text/x-vCard";
        System.IO.StringWriter stringWrite = new System.IO.StringWriter();
        System.Web.UI.HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite);

            {
                response.AddHeader("content-disposition", "attachment; filename=" + usr.SamAccountName);

                stringWrite.WriteLine("BEGIN:VCARD");
                stringWrite.WriteLine("VERSION:2.1");
                //Name
                stringWrite.WriteLine("N:" + usr.LastName + ";" + usr.FirstName
                    );
               //removed other vcard lines....

                //vCard End
                stringWrite.WriteLine("END:VCARD");
                response.Write(stringWrite.ToString());
                response.End();
            }
    }
4

1 に答える 1

1

Response.WriteResponse が完全に形成されてブラウザに送り返される前にを使用すると、文字列がストリームの先頭に書き込まれます。

実際には、このニーズに対応する特定の方法がありますClientScriptManager.RegisterClientScriptBlock

ClientScript.RegisterClientScriptBlock(this.GetType(), "scriptKeyNameCanBeAnythingYouWant", "var
                    @" win=window.open('vCard.aspx',null,'width=50,height=50," +
                    @"top=100,left=100','true');", true);

のリファレンスClientScriptManager.RegisterClientScriptBlock: http://msdn.microsoft.com/en-us/library/bahh2fef.aspx

于 2013-01-20T02:03:32.157 に答える