Welcome Guest Search | Active Topics | Sign In | Register

How to close a flyout Options
WMP
Posted: Monday, September 5, 2011 5:32:22 AM
Rank: Advanced Member
Groups: Member

Joined: 7/6/2011
Posts: 30
I want to simply to close a flyout on the client side from a button within the flyout. What is the best way to go about it please?
eo_support
Posted: Monday, September 5, 2011 8:50:54 AM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
Hi,

You can use the following code to close a flyout:

Code: JavaScript
//Get the client side Flyout object
var flyout = eo_GetObject("<%=Flyout1.ClientID%>");

//Close the flyout
flyout.hide();


Thanks
WMP
Posted: Monday, September 5, 2011 12:30:59 PM
Rank: Advanced Member
Groups: Member

Joined: 7/6/2011
Posts: 30
Great, thank you!
WMP
Posted: Tuesday, September 6, 2011 11:50:26 AM
Rank: Advanced Member
Groups: Member

Joined: 7/6/2011
Posts: 30
Ah - now I'm getting the error "The name 'Flyout1' does not exist in the current context" - I have the flyout inside a repeater. Any thoughts on how I should reference the object would be much appreciated.
eo_support
Posted: Tuesday, September 6, 2011 12:17:25 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
Hi,

You can do something like this:

Code: HTML/ASPX
<asp:Repeater runat="server" ID="rpt1">
  <ItemTemplate>
      <asp:Button runat="server" ID="Button1" Text="Button1" />
      <eo:Flyout runat="server" ID="Flyout1" For="Button1">
          <ContentTemplate>
              <div onclick='hideFlyout("<%#GetFlyoutID(Container)%>")';>
                  test 1
              </div>
          </ContentTemplate>
      </eo:Flyout>
  </ItemTemplate>
</asp:Repeater>


hideFlyout is a JavaScript function:

Code: JavaScript
function hideFlyout(flyoutId) 
{
    //Get the client side Flyout control
    var flyout = eo_GetObject(flyoutId);

    //Hide the flyout
    flyout.hide();
}


GetFlyoutID is a code behind function:

Code: C#
protected string GetFlyoutID(object container)
{
    //Cast the container into a RepeaterItem. Note this only
    //works for a repeater. If your control is not a Repeater,
    //then you will need to change the type here accordingly
    RepeaterItem item = (RepeaterItem)container;

    //Find the flyout control and returns its ClientID
    return item.FindControl("Flyout1").ClientID;
}


Hope this helps. Please feel free to let us know if you have any more questions.

Thanks!

WMP
Posted: Tuesday, September 6, 2011 12:22:58 PM
Rank: Advanced Member
Groups: Member

Joined: 7/6/2011
Posts: 30
YES! It works, thank you so much.
eo_support
Posted: Tuesday, September 6, 2011 12:26:10 PM
Rank: Administration
Groups: Administration

Joined: 5/27/2007
Posts: 24,194
Great. Please feel free to let us know if you have any more questions.

Thanks!


You cannot post new topics in this forum.
You cannot reply to topics in this forum.
You cannot delete your posts in this forum.
You cannot edit your posts in this forum.
You cannot create polls in this forum.
You cannot vote in polls in this forum.