Solved

asp.net multview active

Posted on 2014-02-10
2
784 Views
Last Modified: 2014-02-26
I try to get the active multiview. but it always return first one. I just want to know
the current active view. How can I do that?

<asp:MultiView ID="VehicleQuoteMV" runat="server" ActiveViewIndex="0">
 <asp:View ID="VehicleQuoteV1" runat="server" />
 <asp:View ID="VehicleQuoteV2" runat="server" />
 <asp:View ID="VehicleQuoteV3" runat="server" />
 </asp:MultiView>

   <%
             Response.Write("Active " & VehicleQuoteMV.GetActiveView.ID)
             
         
          %>
0
Comment
Question by:CoolDev2014
2 Comments
 
LVL 11

Accepted Solution

by:
SAMIR BHOGAYTA earned 500 total points
ID: 39849253
hi.. You can do this using javascript

<script type="text/javascript">
    var CurrentView = <%= MultiView1.ActiveViewIndex %>
     alert("Current Active View Index Is :"+CurrentView);
</script>

if your MultiView is Inside the Update Panel then Code like below

<script type="text/javascript">
var CurrentView = <%=(UpdatePanel1.FindControl("MultiView1") as MultiView).ActiveViewIndex %>
alert("Current Active View Index Is :"+CurrentView);
</script>

Example

Code Behind

  protected void Page_Load(object sender, EventArgs e)
  {
    (UpdatePanel1.FindControl("MultiView1") as MultiView).ActiveViewIndex = 1;
  }

ASPX Code

<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>

<script type="text/javascript">
var CurrentView = <%=  (UpdatePanel1.FindControl("MultiView1") as MultiView).ActiveViewIndex %>
alert("Current Active View Index Is :"+CurrentView);
</script>
</div>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
  <ContentTemplate>
    <asp:MultiView ID="MultiView1" runat="server">
      <asp:View ID="View1" runat="server">
        View1
      </asp:View>
      <asp:View ID="View2" runat="server">
        View2
      </asp:View>
      <asp:View ID="View3" runat="server">
        View3
      </asp:View>
    </asp:MultiView>
  </ContentTemplate>
</asp:UpdatePanel>
</form>
0
 

Author Comment

by:CoolDev2014
ID: 39849508
it is using update panel, and I put below codes but it does not do anything. Regardless it page onload or after the button is clicked. It has nothing happened.

Thanks

<script type="text/javascript">
var CurrentView = <%=(UpdatePanel1.FindControl("MultiView1") as MultiView).ActiveViewIndex %>
alert("Current Active View Index Is :"+CurrentView);
</script>
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

In my previous two articles we discussed Binary Serialization (http://www.experts-exchange.com/A_4362.html) and XML Serialization (http://www.experts-exchange.com/A_4425.html). In this article we will try to know more about SOAP (Simple Object Acces…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
Along with being a a promotional video for my three-day Annielytics Dashboard Seminor, this Micro Tutorial is an intro to Google Analytics API data.
The Email Laundry PDF encryption service allows companies to send confidential encrypted  emails to anybody. The PDF document can also contain attachments that are embedded in the encrypted PDF. The password is randomly generated by The Email Laundr…

776 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