views:

264

answers:

2

Hi,

I want do Fancybox work without a click. I want fancybox work as a alert in onload.

A: 

You can register it to run when the page loads using RegisterStartupScript(), like this:

string myScript = "$('#myFancybox').fancybox();" //add options if needed
ClientScript.RegisterStartupScript(typeof(Page), "alert", script, true);
Nick Craver
Ok, but #myFancybox can be a div?
Diego Dias
@Diego - Yup a `<div id="myFancybox">` would work :)
Nick Craver
A: 

I do test and no works.

content .cs protected void Page_Load(object sender, EventArgs e) { Presenter.InitializeView(this);

    string myScript = "$('#divMessageBox').fancybox();";
    ClientScript.RegisterStartupScript(typeof(Page), "alert", myScript, true);
}

content .aspx

<div id="divMessageBox" style="width:400px;height:100px;overflow:auto;">
            <asp:Label ID="lblMessage" runat="server" Text="testando Fancybox" />
        </div>

Anyone have any suggestions?

Diego Dias