How to achiev these two things.... ...

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Benjamin Smith

    How to achiev these two things.... ...


    Copy and paste this code in the HTML section of the page

    1. Why I am using hidden varaible here?
    Currently user can click on hide/show link. If the application is in display
    mode (I mean the hidden data is displayed) and if the user clicks the
    button, the post back happens and the user selected display mode will be
    gone. To avoid that I am trying to keep the user opted mode using hidden
    control and trying to restore the same value after postback. How to do that?

    2. Currently this part of my code appears almost at the end of the page
    where user has clicked vertical scroll bar to get into this section. After
    scrolling down if the clicks the hide/show link the data will be
    displayed/hidden but the user will be shown the top of the page. Some thing
    like my smart navaigation is not effective. I know I am not posting the page
    back when the user clicks on the hide/show link. But how to restore the
    vertical postion of the form when the user clicks on hid/show button.

    Your comments and suggestions are highly appreciated.

    Benjamin


    <%@ Page Language="vb" AutoEventWireup ="false" Codebehind="Web Form1.aspx.vb"
    Inherits="HomeT estApp.WebForm1 "%>
    <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    <HTML>
    <HEAD>
    <title>WebForm1 </title>
    <meta name="GENERATOR " content="Micros oft Visual Studio .NET 7.1">
    <meta name="CODE_LANG UAGE" content="Visual Basic .NET 7.1">
    <meta name="vs_defaul tClientScript" content="JavaSc ript">
    <meta name="vs_target Schema"
    content="http://schemas.microso ft.com/intellisense/ie5">
    <script language="javas cript">
    <!--
    function hideshow(obj)
    {
    if (document.getEl ementById(obj). style.display == "block")
    document.getEle mentById(obj).s tyle.display = "none";
    else
    document.getEle mentById(obj).s tyle.display = "block";
    }
    //-->
    </script>
    </HEAD>
    <body MS_POSITIONING= "GridLayout ">
    <form id="Form1" method="post" runat="server">
    <TABLE width="100%" id="Table1" cellSpacing="1" cellPadding="1"
    border="1">
    <tr>
    <td><a href="#" onclick="hidesh ow('row5')">Hid e Show</a><INPUT
    type="hidden" id="hdnRowSts" value="none" name="hdnRowSts "></td>
    </tr>
    <tr id="row5" style="DISPLAY: none">
    <TD>
    <asp:Label id="Label1" runat="server"> Label1</asp:Label></TD>
    </tr>
    <tr>
    <td>
    <asp:Label id="Label2" runat="server"> Label2</asp:Label>
    <asp:Button id="btnDoPostBa ck" runat="server"
    Text="btnDoPost Back"></asp:Button></td>
    </tr>
    </TABLE>
    </form>
    </body>
    </HTML>



  • Karl Seguin

    #2
    Re: How to achiev these two things.... ...

    Benjamin:
    Your 2nd problem can be fixed by changing the <a> tag to:
    <a href="javascrip t:hideshow('row 5')">

    the problem with yours is that you have an href="#" which means top of page,
    so the onlick event fires then the link is followed (to the top of page),
    the syntax provided will work in all browsers.


    For your first problem I think your on the right track. Store the value in
    a hidden field, and toggle it in your codebehind, something like:

    function hideshow(obj)
    {
    if (document.getEl ementById(obj). style.display == "block")
    document.getEle mentById(obj).s tyle.display = "none";
    else
    document.getEle mentById(obj).s tyle.display = "block";
    document.getEle mentById("hdnRo wSts").value =
    document.getEle mentById(obj).s tyle.display;
    }


    and in your codebehind, simply putting the following in your page_load
    should work:

    If Not Request.Form("h dnRowSts") Is Nothing Then
    row5.Style.Add( "display", Request.Form("h dnRowSts"))
    Else
    row5.Style.Add( "display", "none")
    End If


    although you might wanna make sure Request.Form("h dnRowSts") is a valid
    value...

    Karl
    --
    MY ASP.Net tutorials
    Programming blog exploring Zig, Elixir, Go, Testing, Design and Performance



    "Benjamin Smith" <BenjaminSmith4 5@hotmail.com> wrote in message
    news:%23Ab1FCXB FHA.2460@TK2MSF TNGP14.phx.gbl. ..[color=blue]
    >
    > Copy and paste this code in the HTML section of the page
    >
    > 1. Why I am using hidden varaible here?
    > Currently user can click on hide/show link. If the application is in[/color]
    display[color=blue]
    > mode (I mean the hidden data is displayed) and if the user clicks the
    > button, the post back happens and the user selected display mode will be
    > gone. To avoid that I am trying to keep the user opted mode using hidden
    > control and trying to restore the same value after postback. How to do[/color]
    that?[color=blue]
    >
    > 2. Currently this part of my code appears almost at the end of the page
    > where user has clicked vertical scroll bar to get into this section. After
    > scrolling down if the clicks the hide/show link the data will be
    > displayed/hidden but the user will be shown the top of the page. Some[/color]
    thing[color=blue]
    > like my smart navaigation is not effective. I know I am not posting the[/color]
    page[color=blue]
    > back when the user clicks on the hide/show link. But how to restore the
    > vertical postion of the form when the user clicks on hid/show button.
    >
    > Your comments and suggestions are highly appreciated.
    >
    > Benjamin
    >
    >
    > <%@ Page Language="vb" AutoEventWireup ="false"[/color]
    Codebehind="Web Form1.aspx.vb"[color=blue]
    > Inherits="HomeT estApp.WebForm1 "%>
    > <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
    > <HTML>
    > <HEAD>
    > <title>WebForm1 </title>
    > <meta name="GENERATOR " content="Micros oft Visual Studio .NET 7.1">
    > <meta name="CODE_LANG UAGE" content="Visual Basic .NET 7.1">
    > <meta name="vs_defaul tClientScript" content="JavaSc ript">
    > <meta name="vs_target Schema"
    > content="http://schemas.microso ft.com/intellisense/ie5">
    > <script language="javas cript">
    > <!--
    > function hideshow(obj)
    > {
    > if (document.getEl ementById(obj). style.display == "block")
    > document.getEle mentById(obj).s tyle.display = "none";
    > else
    > document.getEle mentById(obj).s tyle.display = "block";
    > }
    > //-->
    > </script>
    > </HEAD>
    > <body MS_POSITIONING= "GridLayout ">
    > <form id="Form1" method="post" runat="server">
    > <TABLE width="100%" id="Table1" cellSpacing="1" cellPadding="1"
    > border="1">
    > <tr>
    > <td><a href="#" onclick="hidesh ow('row5')">Hid e Show</a><INPUT
    > type="hidden" id="hdnRowSts" value="none" name="hdnRowSts "></td>
    > </tr>
    > <tr id="row5" style="DISPLAY: none">
    > <TD>
    > <asp:Label id="Label1" runat="server"> Label1</asp:Label></TD>
    > </tr>
    > <tr>
    > <td>
    > <asp:Label id="Label2" runat="server"> Label2</asp:Label>
    > <asp:Button id="btnDoPostBa ck" runat="server"
    > Text="btnDoPost Back"></asp:Button></td>
    > </tr>
    > </TABLE>
    > </form>
    > </body>
    > </HTML>
    >
    >
    >[/color]


    Comment

    • Benjamin Smith

      #3
      Re: How to achiev these two things.... ...

      Karl,
      Problem 2 got fixed as per your suggestions. Thanks a lot.
      Problem 1. I do not understand how one can access the client side Id in a
      server side code.
      row5.Style.Add( "display", Request.Form("h dnRowSts"))
      When I put the above code it says variable not declared.
      Benjamin



      "Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net>
      wrote in message news:e3D3PiXBFH A.2392@TK2MSFTN GP14.phx.gbl...[color=blue]
      > Benjamin:
      > Your 2nd problem can be fixed by changing the <a> tag to:
      > <a href="javascrip t:hideshow('row 5')">
      >
      > the problem with yours is that you have an href="#" which means top of[/color]
      page,[color=blue]
      > so the onlick event fires then the link is followed (to the top of page),
      > the syntax provided will work in all browsers.
      >
      >
      > For your first problem I think your on the right track. Store the value[/color]
      in[color=blue]
      > a hidden field, and toggle it in your codebehind, something like:
      >
      > function hideshow(obj)
      > {
      > if (document.getEl ementById(obj). style.display == "block")
      > document.getEle mentById(obj).s tyle.display = "none";
      > else
      > document.getEle mentById(obj).s tyle.display = "block";
      > document.getEle mentById("hdnRo wSts").value =
      > document.getEle mentById(obj).s tyle.display;
      > }
      >
      >
      > and in your codebehind, simply putting the following in your page_load
      > should work:
      >
      > If Not Request.Form("h dnRowSts") Is Nothing Then
      > row5.Style.Add( "display", Request.Form("h dnRowSts"))
      > Else
      > row5.Style.Add( "display", "none")
      > End If
      >
      >
      > although you might wanna make sure Request.Form("h dnRowSts") is a valid
      > value...
      >
      > Karl
      > --
      > MY ASP.Net tutorials
      > http://www.openmymind.net/
      >
      >
      > "Benjamin Smith" <BenjaminSmith4 5@hotmail.com> wrote in message
      > news:%23Ab1FCXB FHA.2460@TK2MSF TNGP14.phx.gbl. ..[color=green]
      > >
      > > Copy and paste this code in the HTML section of the page
      > >
      > > 1. Why I am using hidden varaible here?
      > > Currently user can click on hide/show link. If the application is in[/color]
      > display[color=green]
      > > mode (I mean the hidden data is displayed) and if the user clicks the
      > > button, the post back happens and the user selected display mode will be
      > > gone. To avoid that I am trying to keep the user opted mode using hidden
      > > control and trying to restore the same value after postback. How to do[/color]
      > that?[color=green]
      > >
      > > 2. Currently this part of my code appears almost at the end of the page
      > > where user has clicked vertical scroll bar to get into this section.[/color][/color]
      After[color=blue][color=green]
      > > scrolling down if the clicks the hide/show link the data will be
      > > displayed/hidden but the user will be shown the top of the page. Some[/color]
      > thing[color=green]
      > > like my smart navaigation is not effective. I know I am not posting the[/color]
      > page[color=green]
      > > back when the user clicks on the hide/show link. But how to restore the
      > > vertical postion of the form when the user clicks on hid/show button.
      > >
      > > Your comments and suggestions are highly appreciated.
      > >
      > > Benjamin
      > >
      > >
      > > <%@ Page Language="vb" AutoEventWireup ="false"[/color]
      > Codebehind="Web Form1.aspx.vb"[color=green]
      > > Inherits="HomeT estApp.WebForm1 "%>
      > > <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
      > > <HTML>
      > > <HEAD>
      > > <title>WebForm1 </title>
      > > <meta name="GENERATOR " content="Micros oft Visual Studio .NET 7.1">
      > > <meta name="CODE_LANG UAGE" content="Visual Basic .NET 7.1">
      > > <meta name="vs_defaul tClientScript" content="JavaSc ript">
      > > <meta name="vs_target Schema"
      > > content="http://schemas.microso ft.com/intellisense/ie5">
      > > <script language="javas cript">
      > > <!--
      > > function hideshow(obj)
      > > {
      > > if (document.getEl ementById(obj). style.display == "block")
      > > document.getEle mentById(obj).s tyle.display = "none";
      > > else
      > > document.getEle mentById(obj).s tyle.display = "block";
      > > }
      > > //-->
      > > </script>
      > > </HEAD>
      > > <body MS_POSITIONING= "GridLayout ">
      > > <form id="Form1" method="post" runat="server">
      > > <TABLE width="100%" id="Table1" cellSpacing="1" cellPadding="1"
      > > border="1">
      > > <tr>
      > > <td><a href="#" onclick="hidesh ow('row5')">Hid e Show</a><INPUT
      > > type="hidden" id="hdnRowSts" value="none" name="hdnRowSts "></td>
      > > </tr>
      > > <tr id="row5" style="DISPLAY: none">
      > > <TD>
      > > <asp:Label id="Label1" runat="server"> Label1</asp:Label></TD>
      > > </tr>
      > > <tr>
      > > <td>
      > > <asp:Label id="Label2" runat="server"> Label2</asp:Label>
      > > <asp:Button id="btnDoPostBa ck" runat="server"
      > > Text="btnDoPost Back"></asp:Button></td>
      > > </tr>
      > > </TABLE>
      > > </form>
      > > </body>
      > > </HTML>
      > >
      > >
      > >[/color]
      >
      >[/color]


      Comment

      • Karl Seguin

        #4
        Re: How to achiev these two things.... ...

        oh..sorry, add runat="server" to the row and declare it as an HtmlTableRow
        ....thus making it a server-side control :)

        Karl

        --
        MY ASP.Net tutorials
        Programming blog exploring Zig, Elixir, Go, Testing, Design and Performance



        "Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net>
        wrote in message news:e3D3PiXBFH A.2392@TK2MSFTN GP14.phx.gbl...[color=blue]
        > Benjamin:
        > Your 2nd problem can be fixed by changing the <a> tag to:
        > <a href="javascrip t:hideshow('row 5')">
        >
        > the problem with yours is that you have an href="#" which means top of[/color]
        page,[color=blue]
        > so the onlick event fires then the link is followed (to the top of page),
        > the syntax provided will work in all browsers.
        >
        >
        > For your first problem I think your on the right track. Store the value[/color]
        in[color=blue]
        > a hidden field, and toggle it in your codebehind, something like:
        >
        > function hideshow(obj)
        > {
        > if (document.getEl ementById(obj). style.display == "block")
        > document.getEle mentById(obj).s tyle.display = "none";
        > else
        > document.getEle mentById(obj).s tyle.display = "block";
        > document.getEle mentById("hdnRo wSts").value =
        > document.getEle mentById(obj).s tyle.display;
        > }
        >
        >
        > and in your codebehind, simply putting the following in your page_load
        > should work:
        >
        > If Not Request.Form("h dnRowSts") Is Nothing Then
        > row5.Style.Add( "display", Request.Form("h dnRowSts"))
        > Else
        > row5.Style.Add( "display", "none")
        > End If
        >
        >
        > although you might wanna make sure Request.Form("h dnRowSts") is a valid
        > value...
        >
        > Karl
        > --
        > MY ASP.Net tutorials
        > http://www.openmymind.net/
        >
        >
        > "Benjamin Smith" <BenjaminSmith4 5@hotmail.com> wrote in message
        > news:%23Ab1FCXB FHA.2460@TK2MSF TNGP14.phx.gbl. ..[color=green]
        > >
        > > Copy and paste this code in the HTML section of the page
        > >
        > > 1. Why I am using hidden varaible here?
        > > Currently user can click on hide/show link. If the application is in[/color]
        > display[color=green]
        > > mode (I mean the hidden data is displayed) and if the user clicks the
        > > button, the post back happens and the user selected display mode will be
        > > gone. To avoid that I am trying to keep the user opted mode using hidden
        > > control and trying to restore the same value after postback. How to do[/color]
        > that?[color=green]
        > >
        > > 2. Currently this part of my code appears almost at the end of the page
        > > where user has clicked vertical scroll bar to get into this section.[/color][/color]
        After[color=blue][color=green]
        > > scrolling down if the clicks the hide/show link the data will be
        > > displayed/hidden but the user will be shown the top of the page. Some[/color]
        > thing[color=green]
        > > like my smart navaigation is not effective. I know I am not posting the[/color]
        > page[color=green]
        > > back when the user clicks on the hide/show link. But how to restore the
        > > vertical postion of the form when the user clicks on hid/show button.
        > >
        > > Your comments and suggestions are highly appreciated.
        > >
        > > Benjamin
        > >
        > >
        > > <%@ Page Language="vb" AutoEventWireup ="false"[/color]
        > Codebehind="Web Form1.aspx.vb"[color=green]
        > > Inherits="HomeT estApp.WebForm1 "%>
        > > <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
        > > <HTML>
        > > <HEAD>
        > > <title>WebForm1 </title>
        > > <meta name="GENERATOR " content="Micros oft Visual Studio .NET 7.1">
        > > <meta name="CODE_LANG UAGE" content="Visual Basic .NET 7.1">
        > > <meta name="vs_defaul tClientScript" content="JavaSc ript">
        > > <meta name="vs_target Schema"
        > > content="http://schemas.microso ft.com/intellisense/ie5">
        > > <script language="javas cript">
        > > <!--
        > > function hideshow(obj)
        > > {
        > > if (document.getEl ementById(obj). style.display == "block")
        > > document.getEle mentById(obj).s tyle.display = "none";
        > > else
        > > document.getEle mentById(obj).s tyle.display = "block";
        > > }
        > > //-->
        > > </script>
        > > </HEAD>
        > > <body MS_POSITIONING= "GridLayout ">
        > > <form id="Form1" method="post" runat="server">
        > > <TABLE width="100%" id="Table1" cellSpacing="1" cellPadding="1"
        > > border="1">
        > > <tr>
        > > <td><a href="#" onclick="hidesh ow('row5')">Hid e Show</a><INPUT
        > > type="hidden" id="hdnRowSts" value="none" name="hdnRowSts "></td>
        > > </tr>
        > > <tr id="row5" style="DISPLAY: none">
        > > <TD>
        > > <asp:Label id="Label1" runat="server"> Label1</asp:Label></TD>
        > > </tr>
        > > <tr>
        > > <td>
        > > <asp:Label id="Label2" runat="server"> Label2</asp:Label>
        > > <asp:Button id="btnDoPostBa ck" runat="server"
        > > Text="btnDoPost Back"></asp:Button></td>
        > > </tr>
        > > </TABLE>
        > > </form>
        > > </body>
        > > </HTML>
        > >
        > >
        > >[/color]
        >
        >[/color]


        Comment

        • Benjamin Smith

          #5
          Re: How to achiev these two things.... ...

          Thanks Karl,
          Both of your suggestions helped me.
          Benjamin


          "Benjamin Smith" <BenjaminSmith4 5@hotmail.com> wrote in message
          news:OuKoN3aBFH A.824@TK2MSFTNG P11.phx.gbl...[color=blue]
          > Karl,
          > Problem 2 got fixed as per your suggestions. Thanks a lot.
          > Problem 1. I do not understand how one can access the client side Id in a
          > server side code.
          > row5.Style.Add( "display", Request.Form("h dnRowSts"))
          > When I put the above code it says variable not declared.
          > Benjamin
          >
          >
          >
          > "Karl Seguin" <karl REMOVE @ REMOVE openmymind REMOVEMETOO . ANDME net>
          > wrote in message news:e3D3PiXBFH A.2392@TK2MSFTN GP14.phx.gbl...[color=green]
          > > Benjamin:
          > > Your 2nd problem can be fixed by changing the <a> tag to:
          > > <a href="javascrip t:hideshow('row 5')">
          > >
          > > the problem with yours is that you have an href="#" which means top of[/color]
          > page,[color=green]
          > > so the onlick event fires then the link is followed (to the top of[/color][/color]
          page),[color=blue][color=green]
          > > the syntax provided will work in all browsers.
          > >
          > >
          > > For your first problem I think your on the right track. Store the value[/color]
          > in[color=green]
          > > a hidden field, and toggle it in your codebehind, something like:
          > >
          > > function hideshow(obj)
          > > {
          > > if (document.getEl ementById(obj). style.display == "block")
          > > document.getEle mentById(obj).s tyle.display = "none";
          > > else
          > > document.getEle mentById(obj).s tyle.display = "block";
          > > document.getEle mentById("hdnRo wSts").value =
          > > document.getEle mentById(obj).s tyle.display;
          > > }
          > >
          > >
          > > and in your codebehind, simply putting the following in your page_load
          > > should work:
          > >
          > > If Not Request.Form("h dnRowSts") Is Nothing Then
          > > row5.Style.Add( "display", Request.Form("h dnRowSts"))
          > > Else
          > > row5.Style.Add( "display", "none")
          > > End If
          > >
          > >
          > > although you might wanna make sure Request.Form("h dnRowSts") is a valid
          > > value...
          > >
          > > Karl
          > > --
          > > MY ASP.Net tutorials
          > > http://www.openmymind.net/
          > >
          > >
          > > "Benjamin Smith" <BenjaminSmith4 5@hotmail.com> wrote in message
          > > news:%23Ab1FCXB FHA.2460@TK2MSF TNGP14.phx.gbl. ..[color=darkred]
          > > >
          > > > Copy and paste this code in the HTML section of the page
          > > >
          > > > 1. Why I am using hidden varaible here?
          > > > Currently user can click on hide/show link. If the application is in[/color]
          > > display[color=darkred]
          > > > mode (I mean the hidden data is displayed) and if the user clicks the
          > > > button, the post back happens and the user selected display mode will[/color][/color][/color]
          be[color=blue][color=green][color=darkred]
          > > > gone. To avoid that I am trying to keep the user opted mode using[/color][/color][/color]
          hidden[color=blue][color=green][color=darkred]
          > > > control and trying to restore the same value after postback. How to do[/color]
          > > that?[color=darkred]
          > > >
          > > > 2. Currently this part of my code appears almost at the end of the[/color][/color][/color]
          page[color=blue][color=green][color=darkred]
          > > > where user has clicked vertical scroll bar to get into this section.[/color][/color]
          > After[color=green][color=darkred]
          > > > scrolling down if the clicks the hide/show link the data will be
          > > > displayed/hidden but the user will be shown the top of the page. Some[/color]
          > > thing[color=darkred]
          > > > like my smart navaigation is not effective. I know I am not posting[/color][/color][/color]
          the[color=blue][color=green]
          > > page[color=darkred]
          > > > back when the user clicks on the hide/show link. But how to restore[/color][/color][/color]
          the[color=blue][color=green][color=darkred]
          > > > vertical postion of the form when the user clicks on hid/show button.
          > > >
          > > > Your comments and suggestions are highly appreciated.
          > > >
          > > > Benjamin
          > > >
          > > >
          > > > <%@ Page Language="vb" AutoEventWireup ="false"[/color]
          > > Codebehind="Web Form1.aspx.vb"[color=darkred]
          > > > Inherits="HomeT estApp.WebForm1 "%>
          > > > <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
          > > > <HTML>
          > > > <HEAD>
          > > > <title>WebForm1 </title>
          > > > <meta name="GENERATOR " content="Micros oft Visual Studio .NET 7.1">
          > > > <meta name="CODE_LANG UAGE" content="Visual Basic .NET 7.1">
          > > > <meta name="vs_defaul tClientScript" content="JavaSc ript">
          > > > <meta name="vs_target Schema"
          > > > content="http://schemas.microso ft.com/intellisense/ie5">
          > > > <script language="javas cript">
          > > > <!--
          > > > function hideshow(obj)
          > > > {
          > > > if (document.getEl ementById(obj). style.display == "block")
          > > > document.getEle mentById(obj).s tyle.display = "none";
          > > > else
          > > > document.getEle mentById(obj).s tyle.display = "block";
          > > > }
          > > > //-->
          > > > </script>
          > > > </HEAD>
          > > > <body MS_POSITIONING= "GridLayout ">
          > > > <form id="Form1" method="post" runat="server">
          > > > <TABLE width="100%" id="Table1" cellSpacing="1" cellPadding="1"
          > > > border="1">
          > > > <tr>
          > > > <td><a href="#" onclick="hidesh ow('row5')">Hid e Show</a><INPUT
          > > > type="hidden" id="hdnRowSts" value="none" name="hdnRowSts "></td>
          > > > </tr>
          > > > <tr id="row5" style="DISPLAY: none">
          > > > <TD>
          > > > <asp:Label id="Label1" runat="server"> Label1</asp:Label></TD>
          > > > </tr>
          > > > <tr>
          > > > <td>
          > > > <asp:Label id="Label2" runat="server"> Label2</asp:Label>
          > > > <asp:Button id="btnDoPostBa ck" runat="server"
          > > > Text="btnDoPost Back"></asp:Button></td>
          > > > </tr>
          > > > </TABLE>
          > > > </form>
          > > > </body>
          > > > </HTML>
          > > >
          > > >
          > > >[/color]
          > >
          > >[/color]
          >
          >[/color]


          Comment

          Working...