Trigger client side java script from formview page index changed event within ajax update panel.

Posted on 2009-12-17
Last Modified: 2012-05-08
I have a .net fromview within an ajax update panel on my page which contains a hiddenfield called hfQuestionNo

as the user pages through the form the hidden field value increments.

The java script i want to run is:'url', 'title', 'width height');
this function opens a lightbox style window.

i need to run it when the hidden field value reaches a value that is specified in either the server side or client side scipt.

I am not really sure where to start.

Many Thanks
Question by:Ross-C
    LVL 11

    Accepted Solution

    Here is my sample project code for you. It calls a javascript alert when the value of the hiddenfield reaches 3:

    in your aspx:
    <asp:ScriptManager ID="ScriptManager1" runat="server">
        <asp:UpdatePanel ID="UpdatePanel1" runat="server">
                <asp:HiddenField ID="HiddenField1" runat="server" />
                <br />
                <asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Button" />
    in the codebehind (.cs):
    protected void Page_Load(object sender, EventArgs e)
            if (!IsPostBack)
                HiddenField1.Value = "0";
        protected void  Button1_Click(object sender, EventArgs e)
            int val = int.Parse(HiddenField1.Value);
            HiddenField1.Value = val.ToString();
            if (val == 3)
                ScriptManager.RegisterStartupScript(this, this.GetType(), "hi", "alert('hi!')", true);

    Open in new window

    LVL 11

    Author Comment

    thanks thats great, i cannot use the page load event though because the form view is in an update panel.  Would like to keep it in the update panel if possible.
    LVL 11

    Expert Comment

    You don't need the page load. I was just setting up the initial value of the HiddenField. It was just an example.
    LVL 11

    Author Comment

    sorry, i wrongly assumed you'd misunderstood my question.  I will give it a go thanks
    LVL 11

    Author Closing Comment

    many thanks, just the job

    Featured Post

    How your wiki can always stay up-to-date

    Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
    - Increase transparency
    - Onboard new hires faster
    - Access from mobile/offline

    Join & Write a Comment

    Suggested Solutions

    Today is the age of broadband.  More and more people are going this route determined to experience the web and it’s multitude of services as quickly and painlessly as possible. Coupled with the move to broadband, people are experiencing the web via …
    ASP.Net to Oracle Connectivity Recently I had to develop an ASP.NET application connecting to an Oracle database.As I am doing it first time ,I had to solve several problems. This article will help to such developers  to develop an ASP.NET client…
    In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    733 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now