0

I got some JQuery code that hides elements on my page. However I would like to keep showing the visible element when a page_load event has appeared.

Im using cshtml(razor) code, and in there I have a IsPost call, and I was wondering if a call to the JQuery .hide was possible.

The JQuery code:

<script>
    $().ready(function () {
        $(".btn").click(function () {
            $(".Hide").hide("fast");
            $("#" + $(this).data('type')).show("fast");
        });
    });
</script>

The C# code:

if(IsPost)
{
    if(Request["btn"] == "btn1")
    {
         // Do some code
    }


    if(Request["btn"] == "btn2")
    {
         // Do some other code
    }
}

The html code:

<div id="button1" class="Hide">
    <form action="" method="post">
        <input type="submit" name="btn" value="btn1" />
    </form>
</div>
<div id="button2" class="Hide">
    <form action="" method="post">
        <input type="submit" name="btn" value="btn2" />
    </form>
</div>
Michael Tot Korsgaard
  • 3,892
  • 11
  • 53
  • 89

1 Answers1

0

The answer I finally used looks like this:

<script>
$().ready(function () {
    $(".btn").click(function () {
        $(".Hide").hide("fast");
        $("#" + $(this).data('type')).show("fast");
    });

    @{
        if(IsPost)
        {
            <text>
                $("#btn1).show("fast");
            </text>
        }
    }
});
</script>
Michael Tot Korsgaard
  • 3,892
  • 11
  • 53
  • 89