0

I have a problem:

I have a 100% dynamic site, which means that I just have one updatepanel on the startpage. All content is added dynamically to default.aspx via code behind, different pages are web user controls.

The problem arises when I want to open 2 windows (drag-able panels via ajax control toolkit).

I want to position these panels via javascript but the positioning javascript does not run.

Note that I'm still on the first page of the web-site, there is no back history in the browser; when I "View source" in the webbrowser I see the code for the login page, which is what comes up first when the website opens.

I don't want any postbacks causing page-history, how can I execute javascript to position my windows?

Solved it

Well I solved this issue by moving the positioning to the server side, I created a "Window Manager" which keeps track of all open windows in the site. I then just put the position by adding the position to the Style attribute in my web user control like so:

    protected void Page_Init(object sender, EventArgs e)
    {
        PartPanel.Attributes.Add("Style", Position);
    }

    public string Position
    {
        get
        {
            return "position:absolute;left:" + PosX "px;top:" + PosY + "px;";
        }
    }
4

3 に答える 3

0

「履歴がない」問題は、FireFox の FireBug プラグインを使用して対処できます。これにより、ライブ ソース コードが表示されます。

これは、サーバーから新しいコードを取得すると思われるブラウザの「右クリック>ソースの表示」オプションよりも大きな利点があります。

于 2011-06-14T16:01:07.440 に答える
0

サンプルコードを教えてください。

このスタイルのコーディングは、コード ビハインド ページにすべてを追加するよりも、一般的なハンドラーを使用する方が簡単で適切ではないでしょうか? これにより、いくつかのオーバーヘッドも解消されると思います。

ソースを表示するには、Chrome の開発者ツール、または Firefox の Firebug などの拡張機能を使用してみてください。このようにして、DOM を表示および操作できます。エラーをログに記録する JavaScript コンソールなど、他の便利なツールもあります。

于 2011-06-14T15:49:23.447 に答える
0
 public void setPage(mshtml.HTMLWindow2Class JSFile) {
        window = JSFile;
}
public void scriptPrint(){
        window.execScript("report_back('Printing complete!')", "JScript");
}

また

Page.RegisterStartupScript("myScript", "<script language=JavaScript>hi('" + whatever + "');</script>");
于 2011-06-14T15:50:15.083 に答える