I have a asp.net Web Application with 2 buttons, label and image Only 1 button is visible when entering the page The when i click the button i want it to show a label, until the code is done in code behind, the show next button and when i click that one i want it to show an image when the code is done
Is that possible in code behind or do i need javascript in the aspx code? I have tried run_button.visible = "false" and so on
The code in the aspx is this:
<head runat="server">
<link href="StyleSheet1.css" rel="stylesheet" />
<title></title>
<form id="form1" runat="server">
<div>
<table>
<tr>
<td class="alignleft">
<img src="Logotyp04.png" class="auto-style6" />
</td>
</tr>
</table>
<table class="header">
<tr>
<td>
<asp:Label ID="Label1" runat="server" Text="Washing Machine" CssClass="label"></asp:Label>
</td>
</tr>
</table>
</div>
<br />
<br />
<br />
<asp:UpdatePanel ID="UpdatePanel1" runat="server"></asp:UpdatePanel>
<div style="text-align:center">
<asp:ImageButton ID="Run_Button" runat="server" ImageAlign="Bottom" ImageUrl="~/download.png" OnClick="run_Click1" OnClientClick="SetButton()" />
<asp:ImageButton ID="Download_Button" runat="server" ImageAlign="Bottom" ImageUrl="~/images.jpg" OnClick="download_Click1" OnClientClick="document.getElementById('Download_Button').style.display = 'none';" />
<asp:Label ID="Label2" Visible="false" runat="server" Text="Working with the laundry..." Height="100px" Width="200px" Font-Bold="True" Font-Size="80px" ForeColor="Red"></asp:Label>
<asp:Image ID="Image1" runat="server" ImageUrl="~/shutterstock_142333726b.jpg" />
</div>
</form>
You can do this with pure 100% server-side controls.
So, right after the form tag, drop in a script manager (this is required for update panels).
Then drop in an update panel.
Then type in this:
Now, just place all of you markup between the above content tags.
The full markup looks like this:
And code behind:
And the result looks like this:
Note that the Progress template will automatically hide, or show DURING server-side processing. However, the content inside can still be changed by code behind.
So, code behind on first button click hides the first div area, and shows the second div area. However, like any server-side code, such changes to the markup (DOM) cannot be seen until code behind running is 100% complete, and that part of the web page travels back down to the client to be rendered in browser. However, the update panel still automatic hides or shows each time for you. And the update panel keeps the settings of the markup we changed above (visible = true/false).
So, on button one click, we have code to hide the button 1 div area - but that update will not take place until button 1 code is done.
Thus, on the next button click (button 2), then the progress template again shows, but this time we have hidden div 1 area, and have shown div 2 area.
As above shows, you can hide or show some content on a button click, and you can conditionally use code behind to hide/show such content.
And you can achieve this without having to write any JavaScript code.
Edit: Example in c#
The markup can be the same, but let's change it a bit anyway.
So, at top of page, right after form tag, we of course drag + drop in a script manager (this is required for update panel).
then our markup of 2 buttons. note how we start out with the second button as visible = false.
So, this markup:
Code behind is this:
And the result is this: