javascript - How to showhide gif image when button click in asp.net - Stack Overflow

I have a asp page where i have a button.When i click on the button i should display a gif image.When th

I have a asp page where i have a button.When i click on the button i should display a gif image.When the process is pleted ,again the images has to be hidden.

Please find my below code behind

<head runat="server">
    <title>Untitled Page</title>

    <script type="text/javascript" language="javascript">

    </script>

</head>
<body>
    <form id="form1" runat="server">
        <div style="display: none" id="dvloader">
            <img src="Images/process_status.gif" /></div>
        <asp:Button ID="btnLoad" runat="server" Text="Load" OnClick="btnLoad_Click" />
    </form>
</body>

Please find the below code behind

 protected void btnLoad_Click(object sender, EventArgs e)
    {
       // Show the gif image
        System.Threading.Thread.Sleep(5000);
        // hide the gif image
    }

How can i achive this ?

Thanks.

I have a asp page where i have a button.When i click on the button i should display a gif image.When the process is pleted ,again the images has to be hidden.

Please find my below code behind

<head runat="server">
    <title>Untitled Page</title>

    <script type="text/javascript" language="javascript">

    </script>

</head>
<body>
    <form id="form1" runat="server">
        <div style="display: none" id="dvloader">
            <img src="Images/process_status.gif" /></div>
        <asp:Button ID="btnLoad" runat="server" Text="Load" OnClick="btnLoad_Click" />
    </form>
</body>

Please find the below code behind

 protected void btnLoad_Click(object sender, EventArgs e)
    {
       // Show the gif image
        System.Threading.Thread.Sleep(5000);
        // hide the gif image
    }

How can i achive this ?

Thanks.

Share Improve this question asked Nov 24, 2009 at 10:28 JebliJebli 2,8257 gold badges31 silver badges37 bronze badges 1
  • you need some progressbar like thing? – Muhammad Akhtar Commented Nov 24, 2009 at 10:35
Add a ment  | 

2 Answers 2

Reset to default 3

The method in your example is server-sided. What you want to do is on the client side and must be done in javascript therefore.

You could use the client-sided onclick-event to show the GIF after the button has been clicked. You can set the client-sided onclick-event somwhere in the Page-Load method for example:

btnLoad.Attributes.Add("onclick", "alert('JavaScript to show GIF goes here...');");

After the PostBack, the GIF will be hidden again automatically...

You could actually apply the event to the element without using the inline event handler.

Using jquery you could say:

 $(document).ready(function() {

$('#btnLoad').click(function(){alert('JavaScript to show GIF goes here...');});


});

This assumes your button has an id of btnload.

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1745062684a4609062.html

相关推荐

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信