Can any one tell me why the page gets refreshed when i'm choosing the option from...

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Mythilisg
    New Member
    • Jan 2008
    • 6

    Can any one tell me why the page gets refreshed when i'm choosing the option from...

    hi,
    i'm working in asp.net with c#.
    i hav one dropdownlist with some options which is similar to Security Questions in yahoo mail.
    I hav one option called "If Others". When the user selects this option, one label and textbox will become visible on the form to type for the user.
    But the problem is when the user chooses the option "If Others", the page gets refreshed. But i dont want the page to get refreshed.
    can any one tell me what i need to do inorder the page not be refreshed. plz.......
  • anandnat
    New Member
    • Feb 2008
    • 2

    #2
    set autopostback=fa lse in dropdownlist & use javascript to check the value if value="if other" then make textbox visibility true using css display:visible ;

    Comment

    • r035198x
      MVP
      • Sep 2006
      • 13225

      #3
      Originally posted by Mythilisg
      hi,
      i'm working in asp.net with c#.
      i hav one dropdownlist with some options which is similar to Security Questions in yahoo mail.
      I hav one option called "If Others". When the user selects this option, one label and textbox will become visible on the form to type for the user.
      But the problem is when the user chooses the option "If Others", the page gets refreshed. But i dont want the page to get refreshed.
      can any one tell me what i need to do inorder the page not be refreshed. plz.......
      Can you post the code?

      Comment

      • anandnat
        New Member
        • Feb 2008
        • 2

        #4
        <script language="javas cript" >

        function checkdrop()
        {
        if(document.get ElementById("my dropdown").valu e=="If other")
        {
        document.getEle mentById("txtdi v").style.displ ay="block";
        }
        }
        </script>

        <body>
        <form id="form1" runat="server">
        <asp:DropDownLi st ID="my_list" runat="server" AutoPostBack="f lase" ></asp:DropDownLis t>
        <div id="txtdiv" style="display: none">
        <asp:TextBox ID="txt_other" runat="server" />
        </div>
        </form>
        </body>

        in codebehind

        protected void Page_Load(objec t sender, EventArgs e)
        {
        my_list.Attribu tes.Add("onchan ge", "javascript:che ckdrop();");
        }

        Comment

        Working...