|
Home > Archive > Microsoft Content Management Server > October 2004 > Custom placeholder and postbacks
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Custom placeholder and postbacks
|
|
| A Louis 2004-10-05, 5:54 pm |
| I am trying to create a placeholder that will display a textbox, a button and
dropdownlist in authoring mode. When the user clicks the button, it brings up
a popup window with a list of postings. After the user selects a posting from
the popup, the textbox in the placeholder is populated with the selected
posting's path. Now the template containing the placeholder fires a postback.
So far everything works. My problem is when the postback happens, the textbox
contents dissappears. Is there anything special I have to do, to handle
postbacks in placeholder or template files? I noticed that when the postback
happens the URL changes from the CMS style to normal asp.net URL.
Any help is greatly appreciated.
Thanks,
Aby.
Here is the code:
protected override void CreateAuthoringChildControls(BaseModeCon
tainer
authoringContainer)
{
this.tbPostingName = new TextBox();
this.tbPostingName.ID = "PostingName";
authoringContainer.Controls.Add(this.tbPostingName);
this.lbBrowse = new LinkButton();
this.lbBrowse.ID = "Browse";
this.lbBrowse.Text = "Select Page";
this.lbBrowse.Click += new EventHandler(lbBrowse_Click);
this.lbBrowse.Attributes.Add("onclick", "return CMS_createLink('" +
tbPostingName.ClientID + "');");
authoringContainer.Controls.Add(this.lbBrowse);
authoringContainer.Controls.Add(new HtmlGenericControl("BR"));
this.dpPlaceholderList = new DropDownList();
this.dpPlaceholderList.ID = "PlaceHolderList";
authoringContainer.Controls.Add(this.dpPlaceholderList);
}
private void lbBrowse_Click(object sender, EventArgs e)
{
EnsureChildControls();
if (this.tbPostingName.Text != "") //<B>This is empty </B>
{
Posting selectedPosting =
(Posting)CmsHttpContext.Current.Searches.GetByPath(this.tbPostingName.Text);
if (selectedPosting != null)
{
foreach (Placeholder ph in selectedPosting.Placeholders)
{
this.dpPlaceholderList.Items.Add(ph.Name);
}
}
}
}
| |
| Stefan [MSFT] 2004-10-06, 2:48 am |
| Hi Aby,
this is more an ASP.NET problem than a MCMS problem.
It seems you need to repopulate the content for some reason.
Might be due to the sequence of the events being fired - a post on a ASP.NET
newsgroup might be more helpful.
What you could do is to repopulate the content from the Request.Form field
for the text box.
Cheers,
Stefan.
--
This posting is provided "AS IS" with no warranties, and confers no rights.
MCMS FAQ:
http://download.microsoft.com/downl...6a/MCMS+2002+-+(complete)+FAQ.htm
MCMS Blog: http://blogs.msdn.com/stefan_gossner/category/4983.aspx
MCMS Sample Code:
http://www.gotdotnet.com/community/...t+S
erver
MCMS Whitepapers and other docs:
http://blogs.msdn.com/stefan_gossne...2/07/41859.aspx
--------------------------------
"A Louis" <ALouis@discussions.microsoft.com> wrote in message
news:9200C3CA-2C91-4A91-9AC5-60154B3A80A4@microsoft.com...
> I am trying to create a placeholder that will display a textbox, a button
and
> dropdownlist in authoring mode. When the user clicks the button, it brings
up
> a popup window with a list of postings. After the user selects a posting
from
> the popup, the textbox in the placeholder is populated with the selected
> posting's path. Now the template containing the placeholder fires a
postback.
> So far everything works. My problem is when the postback happens, the
textbox
> contents dissappears. Is there anything special I have to do, to handle
> postbacks in placeholder or template files? I noticed that when the
postback
> happens the URL changes from the CMS style to normal asp.net URL.
>
> Any help is greatly appreciated.
>
> Thanks,
> Aby.
>
> Here is the code:
> protected override void CreateAuthoringChildControls(BaseModeCon
tainer
> authoringContainer)
> {
> this.tbPostingName = new TextBox();
> this.tbPostingName.ID = "PostingName";
> authoringContainer.Controls.Add(this.tbPostingName);
> this.lbBrowse = new LinkButton();
> this.lbBrowse.ID = "Browse";
> this.lbBrowse.Text = "Select Page";
> this.lbBrowse.Click += new EventHandler(lbBrowse_Click);
> this.lbBrowse.Attributes.Add("onclick", "return CMS_createLink('" +
> tbPostingName.ClientID + "');");
> authoringContainer.Controls.Add(this.lbBrowse);
> authoringContainer.Controls.Add(new HtmlGenericControl("BR"));
>
> this.dpPlaceholderList = new DropDownList();
> this.dpPlaceholderList.ID = "PlaceHolderList";
> authoringContainer.Controls.Add(this.dpPlaceholderList);
> }
>
> private void lbBrowse_Click(object sender, EventArgs e)
> {
> EnsureChildControls();
> if (this.tbPostingName.Text != "") //<B>This is empty </B>
> {
> Posting selectedPosting =
>
(Posting)CmsHttpContext.Current.Searches.GetByPath(this.tbPostingName.Text);
> if (selectedPosting != null)
> {
> foreach (Placeholder ph in selectedPosting.Placeholders)
> {
> this.dpPlaceholderList.Items.Add(ph.Name);
> }
> }
> }
> }
>
| |
| A Louis 2004-10-07, 11:20 am |
| Stefan,
Now I got the placeholder working for the most part except one glitch. When
doing an authoringpreview my dropdownlist is still empty during the
SavePlaceholderContent() event. I am also calling the EnsureChildControls()
method within this method. But the same method SavePlaceholderContent() is
sucessful when saving the posting. Also I can preview the page when the page
is edit mode.
Is there anything else I have to do when dealing with asp.net controls?
Is there any sample code out there where a dropdownlist control is used in a
custom placeholder? Most the of the sample code out there uses html controls
instead of .net server controls.
Note: I am trying to create a RenderPlaceholder control like the one you
developed where the user can set the posting and placeholder name at
authoring time instead of the template design time. I have a textbox, a link
button and a dropdownlist control in my placeholder.
Your help is greatly appreciated.
Thanks,
Aby
"Stefan [MSFT]" wrote:
> Hi Aby,
>
> this is more an ASP.NET problem than a MCMS problem.
> It seems you need to repopulate the content for some reason.
> Might be due to the sequence of the events being fired - a post on a ASP.NET
> newsgroup might be more helpful.
>
> What you could do is to repopulate the content from the Request.Form field
> for the text box.
>
> Cheers,
> Stefan.
>
> --
> This posting is provided "AS IS" with no warranties, and confers no rights.
>
> MCMS FAQ:
> http://download.microsoft.com/downl...6a/MCMS+2002+-+(complete)+FAQ.htm
> MCMS Blog: http://blogs.msdn.com/stefan_gossner/category/4983.aspx
> MCMS Sample Code:
> http://www.gotdotnet.com/community/...t+S
erver
> MCMS Whitepapers and other docs:
> http://blogs.msdn.com/stefan_gossne...2/07/41859.aspx
> --------------------------------
>
>
> "A Louis" <ALouis@discussions.microsoft.com> wrote in message
> news:9200C3CA-2C91-4A91-9AC5-60154B3A80A4@microsoft.com...
> and
> up
> from
> postback.
> textbox
> postback
> (Posting)CmsHttpContext.Current.Searches.GetByPath(this.tbPostingName.Text);
>
>
>
| |
| Stefan [MSFT] 2004-10-07, 11:20 am |
| Hi Aby,
I never tested my placeholder controls in preview mode - so no idea if it
works or not.
Just try it:
http://www.gotdotnet.com/Community/...c8-e8feb9a1fbeb
Cheers,
Stefan.
--
This posting is provided "AS IS" with no warranties, and confers no rights.
MCMS FAQ:
http://download.microsoft.com/downl...6a/MCMS+2002+-+(complete)+FAQ.htm
MCMS Blog: http://blogs.msdn.com/stefan_gossner/category/4983.aspx
MCMS Sample Code:
http://www.gotdotnet.com/community/...t+S
erver
MCMS Whitepapers and other docs:
http://blogs.msdn.com/stefan_gossne...2/07/41859.aspx
--------------------------------
"A Louis" <ALouis@discussions.microsoft.com> wrote in message
news:B17E0C4F-7B19-47A5-BB17-C620CDEA2E25@microsoft.com...
> Stefan,
>
> Now I got the placeholder working for the most part except one glitch.
When
> doing an authoringpreview my dropdownlist is still empty during the
> SavePlaceholderContent() event. I am also calling the
EnsureChildControls()
> method within this method. But the same method SavePlaceholderContent() is
> sucessful when saving the posting. Also I can preview the page when the
page
> is edit mode.
>
> Is there anything else I have to do when dealing with asp.net controls?
>
> Is there any sample code out there where a dropdownlist control is used in
a
> custom placeholder? Most the of the sample code out there uses html
controls
> instead of .net server controls.
>
> Note: I am trying to create a RenderPlaceholder control like the one you
> developed where the user can set the posting and placeholder name at
> authoring time instead of the template design time. I have a textbox, a
link[vbcol=seagreen]
> button and a dropdownlist control in my placeholder.
>
> Your help is greatly appreciated.
>
> Thanks,
> Aby
>
> "Stefan [MSFT]" wrote:
>
ASP.NET[vbcol=seagreen]
field[vbcol=seagreen]
rights.[vbcol=seagreen]
http://download.microsoft.com/downl...6a/MCMS+2002+-+(complete)+FAQ.htm[vbcol=seagreen]
http://www.gotdotnet.com/community/...t+S
erver[vbcol=seagreen]
button[vbcol=seagreen]
brings[vbcol=seagreen]
posting[vbcol=seagreen]
selected[vbcol=seagreen]
handle[vbcol=seagreen]
(Posting)CmsHttpContext.Current.Searches.GetByPath(this.tbPostingName.Text);[vbcol=seagreen]
|
|
|
|
|