Solved

asp.net multview active

Posted on 2014-02-10
2
748 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
Comment Utility
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
Comment Utility
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

Find Ransomware Secrets With All-Source Analysis

Ransomware has become a major concern for organizations; its prevalence has grown due to past successes achieved by threat actors. While each ransomware variant is different, we’ve seen some common tactics and trends used among the authors of the malware.

Join & Write a Comment

In my previous article (http://www.experts-exchange.com/Programming/Languages/.NET/.NET_Framework_3.x/A_4362-Serialization-in-NET-1.html) we saw the basics of serialization and how types/objects can be serialized to Binary format. In this blog we wi…
Today I had a very interesting conundrum that had to get solved quickly. Needless to say, it wasn't resolved quickly because when we needed it we were very rushed, but as soon as the conference call was over and I took a step back I saw the correct …
Here's a very brief overview of the methods PRTG Network Monitor (https://www.paessler.com/prtg) offers for monitoring bandwidth, to help you decide which methods you´d like to investigate in more detail.  The methods are covered in more detail in o…
This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor (https://www.paessler.com/prtg). If you're looking for how to monitor bandwidth using netflow or packet s…

763 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

13 Experts available now in Live!

Get 1:1 Help Now