Click here to Skip to main content
15,897,718 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
My design contain two placeholders: placeholder1 and placeholder2 and two buttons: display1 and display2.

Placeholder1 contains Image, placeholder2 contains calender.

When I click the display1 button, the image is opened. When I click the display2 button, the calendar is opened but at same time, Placeholder1 is closed and vice versa.

I want placeholder1 to stay open when placeholder2 is opening and placeholder2 to stay open when placeholder1 is opening.

They should not close each other.

Please help me.
Please give full code (not in VB.net).
Please urgent.
Posted
Updated 5-Jul-10 6:53am
v4
Comments
R. Giskard Reventlov 5-Jul-10 10:03am    
Very hard to understand what you are asking: format your question properly so it is readable.
Johnny J. 5-Jul-10 10:11am    
I have formatted the question now. It would be a good idea if you could do it yourself the next time. Writing readable text (including line breaks, spaces after '.' and capital letters where applicable) is showing consideration for the readers and is more likely to get you answers than being lazy...

Don't pass the selection as page-generation criteria, rather store the user selection in the session. For example:

Session("image-choice") = "filename.jpg"


When you're loading the page, check the session for both selections and load the content that has been selected.

Cheers.
 
Share this answer
 
Check this code. i answer this type of question yesterday in dotnetspider.

<![CDATA[<%@ Page Language="C#" AutoEventWireup="true" CodeFile="placeholderissue.aspx.cs" Inherits="placeholderissue" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
    <title></title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        <asp:Button ID="Button1" runat="server" Text="Display1"
            onclick="Button1_Click" />
        <asp:Button ID="Button2"
            runat="server" Text="Display2" onclick="Button2_Click" />
        <br />
        <asp:PlaceHolder ID="PlaceHolder1" runat="server"></asp:PlaceHolder> <br />
        <asp:PlaceHolder ID="PlaceHolder2" runat="server"></asp:PlaceHolder>
    </div>
    </form>
</body>
</html>








using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

public partial class placeholderissue : System.Web.UI.Page
{
    protected void Page_Load(object sender, EventArgs e)
    {
        if (IsPostBack)
        {
            if (Display1)
            {
                if (PlaceHolder1.FindControl("Calendar1") == null)
                {
                    Calendar calender1 = new Calendar();
                    calender1.ID = "Calendar1";
                    PlaceHolder1.Controls.Add(calender1);
                    PlaceHolder1.Visible = true;
                }
            }
            if (Display2)
            {
                if (PlaceHolder2.FindControl("FileUpload1") == null)
                {
                    FileUpload fup = new FileUpload();
                    fup.ID = "FileUpload1";
                    PlaceHolder2.Controls.Add(fup);
                    PlaceHolder2.Visible = true;
                }
            }
        }
        else
        {
            PlaceHolder1.Visible = false;
            PlaceHolder2.Visible = false;
        }
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        if (PlaceHolder1.FindControl("Calendar1") == null)
        {
            Calendar calender1 = new Calendar();
            calender1.ID = "Calendar1";
            PlaceHolder1.Controls.Add(calender1);
            PlaceHolder1.Visible = true;
            Display1 = true;
        }
       
    }
    protected void Button2_Click(object sender, EventArgs e)
    {
        if (PlaceHolder2.FindControl("FileUpload1") == null)
        {
            FileUpload fup = new FileUpload();
            fup.ID = "FileUpload1";
            PlaceHolder2.Controls.Add(fup);
            PlaceHolder2.Visible = true;
            Display2 = true;
        }
    }
    public bool Display1 {
        get
        {
            object o = ViewState["_Display1"];
            if (o == null)
                return false;
            else
                return (bool)ViewState["_Display1"];
        }
        set
        {
            ViewState["_Display1"] = value;
        }
    }
    public bool Display2
    {
        get
        {
            object o = ViewState["_Display2"];
            if (o == null)
                return false;
            else
                return (bool)ViewState["_Display2"];
        }
        set
        {
            ViewState["_Display2"] = value;
        }
    }
}
%>]]>
 
Share this answer
 
Try this:-


Step 1:-

I use two PlaceHolder(PlaceHolder1,PlaceHolder2) and Two Buttons(Display1,Display2) .In PlaceHolder1,There is an Image(Image1) and in PlaceHolder2,there is a Calendar.Set the Visible property(Visible="false") of Image and Calendar Control


<asp:PlaceHolder ID="PlaceHolder1" runat="server"><asp:Image ID="Image1" Visible="false" Height="100px" runat="server" ImageUrl="Blue hills.jpg" /></asp:PlaceHolder>
<br />
<br />
<asp:PlaceHolder ID="PlaceHolder2" runat="server">
<asp:Calendar ID="Calendar1" Visible="false" runat="server"></asp:Calendar>
</asp:PlaceHolder>
<asp:Button ID="Display1" runat="server" Text="Display1" OnClick="Display1_Click" />
<asp:Button ID="Display2"
runat="server" Text="Display2" OnClick="Display2_Click" />



Step 2:-

Write the following code to visible both controls(Image and Calendar) on the Click of both Display Buttons.


protected void Display1_Click(object sender, EventArgs e)
{
Image1.Visible = true;
}
protected void Display2_Click(object sender, EventArgs e)
{
Calendar1.Visible = true;
}
 
Share this answer
 

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