Click here to Skip to main content
15,867,686 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
hi every body,,

i have a login page that contains 2 text boxes and button. i want to add image control to page as style. when i run program the image not display., it is appear just as (x) or unavailable. then when i logout from my page and redirect to the same login page the image appear!!. why thats happen.

what i want is when i run the project (the login is start page) the image appear.


thank you
Posted
Comments
Suvendu Shekhar Giri 22-Feb-15 6:45am    
Does the login page has a MasterPage? Can you share the folder structure where Login page resides and the folder containing the image ? Also share the concerned code snippet. That will help deriving a perfect working solution to your problem :)
Badour alsamaraie 23-Feb-15 0:52am    
okay, My login.aspx page is such as :

<form id="form1" runat="server">
<div>
<asp:Image ID="Image1" runat="server" ImageAlign="Middle"/>

<br />
<br />
                                                      <br />
                                                               
<asp:Label ID="Label1" runat="server" Text="User Name" Font-Bold="True"
Font-Size="Large" ForeColor="#FF6600">
     
<asp:TextBox ID="TextBox1" runat="server" style="margin-bottom: 0px">
<br />
<br />
                                                                <asp:Label ID="Label2" runat="server" Text="Password" Font-Bold="True"
Font-Size="Large" ForeColor="#FF6600">
        
<asp:TextBox ID="TextBox2" runat="server">
<br />
<br />                                                                                       
<asp:Button ID="Button1" runat="server" Text="SignIn"
onclick="Button1_Click1" Font-Bold="True" ForeColor="#FF6600"
Height="37px" Width="70px" />

</div>
</form>
____________________________________
my login .apx.cs

protected void Page_Load(object sender, EventArgs e)
{
Image1.ImageUrl = "~/Images/LiveRadio.jpg";
}
[no name] 23-Feb-15 0:27am    
Check ur image path before and after the pagload..
Badour alsamaraie 23-Feb-15 0:47am    
image path is okay !!
[no name] 23-Feb-15 1:11am    
It's working fine for me.

Why don't you give the image url from you source page if you want that on the pageload ?
This should do the job-
ASP.NET
<asp:image id="Image1" runat="server" imagealign="Middle" imageurl="~/Images/LiveRadio.jpg" xmlns:asp="#unknown"></asp:image>


Make sure that you have browsed the url instead of copy past or writing manually.

Hope, this helps :)

Update

Make sure that you have commented following
C#
protected void Page_Load(object sender, EventArgs e)
{
     //Image1.ImageUrl = "~/Images/LiveRadio.jpg";
}
 
Share this answer
 
v2
Comments
Badour alsamaraie 24-Feb-15 3:11am    
Unfortunately that is not work !
Suvendu Shekhar Giri 24-Feb-15 4:30am    
make sure that you have commented the page_load logic.
Add a master page like LoginMaster.master in your solutions and add all the styling required for Login.aspx in the same. At the same time you add left and right logos etc. if you want to display at the top of the login page. Create the required Login.aspx using LoginMaster.master.

Hope that helps,
Thanks
 
Share this answer
 
Comments
Badour alsamaraie 23-Feb-15 0:49am    
i dont want to add login in master page, i am using <authentication> in web.config so when client write application Url he/she must log in before going to master page
Inside the body tag :

XML
<form id="form1" runat="server">
<div>
<asp:Image ID="Image1" runat="server" ImageAlign="Middle"/>

<br />
<br />
                                                      <br />

<asp:Label ID="Label1" runat="server" Text="User Name" Font-Bold="True"
Font-Size="Large" ForeColor="#FF6600"></asp:Label>

<asp:TextBox ID="TextBox1" runat="server" style="margin-bottom: 0px"></asp:TextBox>
<br />
<br />
                                                                <asp:Label ID="Label2" runat="server" Text="Password" Font-Bold="True"
Font-Size="Large" ForeColor="#FF6600"></asp:Label>

<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
<br />
<br />


</div>
</form>


Code behind :

C#
protected void Page_Load(object sender, EventArgs e)
   {
       Image1.ImageUrl = "~/Images/LiveRadio.jpg";
   }
 
Share this answer
 
Comments
Badour alsamaraie 23-Feb-15 1:20am    
i am already put <body><form><div>.....</div></form></body>
[no name] 23-Feb-15 1:24am    
create a new project and try the above code mr codemaster
Badour alsamaraie 23-Feb-15 2:07am    
the same problem i tried your code but no image appear just label and textbox. when i run on other project it works properly
[no name] 23-Feb-15 2:10am    
Other projects means ?
Badour alsamaraie 23-Feb-15 2:18am    
yes, i tried new web application project and put image, labels and textboxes in the login page and it worked correctly. But i think i fetch the problem. the problem when i add authentication code to web.config

<authentication mode="Forms">
<forms loginUrl="WebForm1.aspx" protection="All" timeout="600" slidingExpiration="true" domain=""/>

<authorization>
<deny users="?">
<allow users="*">

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900