Solved

asp.net multview active

Posted on 2014-02-10
2
807 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

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…
Problem Hi all,    While many today have fast Internet connection, there are many still who do not, or are connecting through devices with a slower connect, so light web pages and fast load times are still popular.    If your ASP.NET page …
Email security requires an ever evolving service that stays up to date with counter-evolving threats. The Email Laundry perform Research and Development to ensure their email security service evolves faster than cyber criminals. We apply our Threat…

756 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