Solved

asp.net multview active

Posted on 2014-02-10
2
828 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

Monthly Recap

May was a big month for new releases from Linux Academy! Take a look at what our team built recently in our blog. You can access the newest releases from our blog.

Question has a verified solution.

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

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…
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 …
Michael from AdRem Software outlines event notifications and Automatic Corrective Actions in network monitoring. Automatic Corrective Actions are scripts, which can automatically run upon discovery of a certain undesirable condition in your network.…
Monitoring a network: why having a policy is the best policy? Michael Kulchisky, MCSE, MCSA, MCP, VTSP, VSP, CCSP outlines the enormous benefits of having a policy-based approach when monitoring medium and large networks. Software utilized in this v…

688 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