Login
Register
Tutorials
Forum
Career Development
Resources
Reviews
Jobs
Interview
Communities
Projects
Training
Silverlight Games
|
Bookmarks
|
New Members FAQ
|
Mentor
|
Code Converter
|
IT Companies
|
Peer Appraisal
|
Members
|
Revenue Sharing
|
Computer Jokes
|
New Posts
|
Social
|
Talk to Webmaster
Tony John
Facebook
Google+
Twitter
LinkedIn
Online Members
lily
Padma
Rakesh Chaubey
Minu
srirama
satyapriyanayak
Saranya
krishnagoluguri@gmail.com
sharmila
parthiban
chandramohan
More...
Join our online
Google+ community
for Bloggers, Content Writers and Webmasters
Forums
»
.NET
»
ASP.NET
»
How to change the image dynamically in master page(using codebehind)
Posted Date:
25 Dec 2011
Posted By::
Ravi
Member Level:
Silver
Member Rank:
1053
Points
: 5
Responses:
1
Hi friends,
my master page is like the following
<asp:ContentPlaceHolder ID="Header" runat="server">
<asp:Image ID="imgHeader" runat="server" ImageAlign="Top" ImageUrl="/IMAGE/ravi1.jpg"/>
</asp:ContentPlaceHolder >
<br />
<br />
<asp:ContentPlaceHolder ID="Content1" runat="server">
</asp:ContentPlaceHolder>
<br />
<br />
<asp:ContentPlaceHolder ID="Footer" runat="server">
<asp:Image ID="Image1" runat="server" ImageAlign= "Bottom" ImageUrl="/IMAGE/redrose1.jpg"/>
</asp:ContentPlaceHolder>
in my content page is
<%@ Page Language="C#" MasterPageFile="~/ImageLayout.Master" AutoEventWireup="true" CodeBehind="Usemas.aspx.cs" Inherits="MasterPageApp.Usemas" %>
<asp:Content ContentPlaceHolderID = "Content1" runat="server">
<br />
<br />
<br />
<br />
<table>
<tr>
<td>
<asp:TextBox ID="txtHeader" runat="server" >
</asp:TextBox>
</td>
<td>
<asp:Button ID="btnHeader" runat="server" Text="Header" onclick="btnHeader_Click" />
</td>
</tr>
<tr>
<td>
<asp:TextBox ID="txtFooter" runat="server">
</asp:TextBox>
</td>
<td>
<asp:Button ID="btnFooter" runat="server" Text="Footer" onclick="btnFooter_Click"/>
</td>
</tr>
<tr>
<td colspan="2">
<asp:Button ID="btnChange" runat="server" Text="ImgCgange"
onclick="btnChange_Click" />
</td>
</tr>
</table>
</asp:Content>
In my content page have 2 texboxes and 2 browse buttons and one image change button.
i got the imageurl path in textbox using browse button
i put the imageurl path in session
Session["Header1"] = txtHeader.Text;
Session["Footer1"] = txtFooter.Text;
then i accessing the session in master page.
MASTER PAGE LOAD EVENT
{
string Head = Convert.ToString(Session["Header1"]);
string Foot = Convert.ToString(Session["Footer"]);
imgHeader.Imageurl=Head;
imgFooter.Imageurl=Foot;
}
But it's not working..
(my logic is i want to change the image in master page based on what i select in the content page textbox )
thanks and regards
Ravi.p
Tweet
Responses
#648608 Author:
Murulidhara K
Member Level:
Bronze
Member Rank:
3616
Date: 26/Dec/2011 Rating:
Points
: 4
If you want to change the image url which is used in master page, you can always do that by overriding the System.Web.UI.Page class method.
protected override void OnPreInit(EventArgs e)
{
base.OnPreInit(e);
// the following line is important
MasterPage master = this.Master;
// unfortunately, compiler warns us that master is not used
// Here find the control to which you want to change the image
// using master, which is the master page. You can identify the //control by using content id.
}
Post Reply
This thread is locked for new responses. Please post your comments and questions as a
separate thread
.
If required, refer to the URL of this page in your
new post
.
Tweet
Next :
Bind image type DB field to Image control
Previous :
Timer Control in asp.net
Return to Discussion Forum
Post New Message
Category:
Related Messages
Validation Controls
no of click on advertisement in asp.net application
Please Please help.................. tooo urgent
Please tell me .Net interview Questions for 2+ Years Exp
To upload Documents like(doc,pdf,etc) to file system
Follow us on Twitter:
https://twitter.com/dotnetspider
Active Members
Today
Deepak Negi
(10)
venkata raju
(8)
Rakesh Chaubey
(6)
Last 7 Days
baskar
(295)
Ultimaterengan
(263)
Rakesh Chaubey
(184)
more...
Awards & Gifts
Email subscription
.NET Jobs
.NET Articles
.NET Forums
Articles Rss Feeds
Forum Rss Feeds
About Us
Contact Us
Copyright
Privacy Policy
Terms Of Use
Revenue Sharing sites
Advertise
Talk to
Tony John
Copyright © SpiderWorks Technologies Pvt Ltd., Kochi, India
2005 - 2012 All Rights Reserved.
.NET and other trademarks mentioned in this site belong to Microsoft and other respective trademark owners.
Articles, tutorials and all other content offered here is for educational purpose only.
We are not associated with Microsoft or its partners.