Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 4620246
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T02:32:04+00:00 2026-05-22T02:32:04+00:00

Why does the below alert always show me null? <%@ Page Language=C# AutoEventWireup=true CodeBehind=Default.aspx.cs

  • 0

Why does the below alert always show me null?

<%@ Page Language="C#" AutoEventWireup="true" CodeBehind="Default.aspx.cs" Inherits="Keyup._Default" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title></title>

<%--    <script src="JQuery/jquery-1.4.1.js" type="text/javascript"></script>--%>
            <script type="text/javascript">

                document.onkeyup = onkeyupOfDocument;

                function onkeyupOfDocument(evt) {
                    //var MultiView = $("*[id$='TextBox1']"); 
                    var MultiView = document.getElementById("MultiView1");
                    alert(MultiView);
                }
    </script>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:MultiView ID="MultiView1" runat="server" ActiveViewIndex="0">
            <asp:View ID="View1" runat="server">
                    <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
            </asp:View>
            <asp:View ID="View2" runat="server">
            </asp:View>
        </asp:MultiView>
    </div>
    </form>
</body>
</html>

After solving null problem how can I check ActiveViewIndex with JavaScript or jQuery?

It seems

if(MultiView.ActiveViewIndex == 0)

is not true!!

Thanks in advance.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-22T02:32:05+00:00Added an answer on May 22, 2026 at 2:32 am

    after our page is completely loaded into the browser & viewing the source code , we can say it’s not possible to CHANGE (Not CHECK) the ActiveViewIndex of Regular MultiView In asp.net with only javascrip or jquery.
    because there is no element out there with MultiView1 id -> just a div Existed.

    we only can check the ActiveViewIndex of MultiView1 as Nathan has answered by below code :

    var activeViewIndex = <%=MultiView1.ActiveViewIndex %>;
    

    plz see the below link for more information (latest post):
    MultiView Is A reach Element
    therefore the below code has no meaning :

    var MultiView = document.getElementById("<%=MultiView1.ClientID %>");
    

    if you want to CHANGE (Not Check) the ActiveViewIndex in client side there is a trick -> plz look at the below codes :

    <%@ Page Language="C#" %>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <script runat="server">
        protected void butSubmit_Click(object sender, EventArgs e)
        {
            MultiView1.ActiveViewIndex = int.Parse(HiddenField1.Value);
        }
    </script>
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title>Demo</title>
    
        <script language="javascript" type="text/ecmascript">
        function OnClientClick( ServerControID,IndexControlID, Index){
            var objDemo = document.getElementById(ServerControID);
            if(objDemo){
                document.getElementById(IndexControlID).value = Index;
                objDemo.click();                        
            }        
        }
        </script>
    
    </head>
    <body>
        <form id="form1" runat="server">
            <div>
                <asp:MultiView ID="MultiView1" runat="server" ActiveViewIndex="0">
                    <asp:View ID="View1" runat="server">
                        <span style="color: #ff0000; background-color: #33ccff"><strong>Hi, I am View 1</strong></span></asp:View>
                    <asp:View ID="View2" runat="server">
                        <strong><span style="color: background; background-color: #99ff00">Hi, I am View 2</span></strong></asp:View>
                </asp:MultiView></div>
            <asp:HiddenField ID="HiddenField1" runat="server" />
            <input id="btnShow1" type="button" value="Show View 1" onclick="OnClientClick('butSubmit','HiddenField1','0')" />
            <input id="btnShow2" type="button" value="Show View 2" onclick="OnClientClick('butSubmit','HiddenField1','1')" />
            <div style="display: none">
                <asp:Button ID="butSubmit" runat="server" OnClick="butSubmit_Click" Text="Submit" /></div>
        </form>
    </body>
    </html>
    

    and here is the source code of the upper codes after the page is loaded in ie 9 :

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head id="Head1"><title>
        Demo
    </title>
    
        <script language="javascript" type="text/ecmascript">
    
            function OnClientClick(ServerControID, IndexControlID, Index) {
                var objDemo = document.getElementById(ServerControID);
                if (objDemo) {
                    document.getElementById(IndexControlID).value = Index;
                    objDemo.click();
                }
            }
        </script>
    
    </head>
    <body>
        <form method="post" action="WebForm3.aspx" id="form1">
    <div class="aspNetHidden">
    <input type="hidden" name="__VIEWSTATE" id="__VIEWSTATE" value="/wEPDwUIODMxNDI3MTNkGAEFCk11bHRpVmlldzEPD2RmZJjYXp6H2AsOwVGwRlIRlk0x9agdyp/Kg++cmPNXKpTg" />
    </div>
    
    <div class="aspNetHidden">
    
        <input type="hidden" name="__EVENTVALIDATION" id="__EVENTVALIDATION" value="/wEWAgKrwZG1BAKQo8KrDX7rF3izcHDs+E9bwpx3GnVGoIZVi2Gpv0IOOu9xXNMo" />
    </div>
            <div>
    
                        <span style="color: #ff0000; background-color: #33ccff"><strong>Hi, I am View 1</strong></span></div>
            <input type="hidden" name="HiddenField1" id="HiddenField1" value="1" />
            <input id="btnShow1" type="button" value="Show View 1" onclick="OnClientClick('butSubmit','HiddenField1','0')" />
            <input id="btnShow2" type="button" value="Show View 2" onclick="OnClientClick('butSubmit','HiddenField1','1')" />
        </form>
    </body>
    </html>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Why does the code below return true only for a = 1? main(){ int
Code below does not run correctly and throws InvalidOperationExcepiton . public void Foo() {
Why does the select statement below return two different values ? declare @tempDec decimal
Does anyone know how to get the below to report a javascript error? (any
The loop below is callign a proc that does various 'things' If it should
Does anyone know of a faster decimal implementation in python? As the example below
In the below code sample, what does {0:X2} mean? This is from the reflection
In the code below, why does the open function work but the close function
SQL Server (2005/2008) Each of the below statements have the same result. Does anyone
edit #2: Question solved halfways. Look below As a follow-up question, does anyone know

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.