Child WebParts in SPS 2003

B

Barbara Alderton

I am working with SharePoint 2003. I am using (using C#)
an existing webpart as a child control (server control).
I need to access/manipulate the HTML that the control
outputs prior to rendering it to the the page. The
control outputs a list in a one-column table format. I
need to access the contents of the rows and output them
with restrictions in my own table format. Does anyone
have any examples of manipulating the HTML of a server
control prior to rendering it to a page or using existing
webparts as child webparts to enhance the functionality?

Thank-you,
Barb
 
G

Guest

Hi Barbara,

Thanks for using Microsoft newsgroup.
My name is Jeffrey, I have reviewed your post, I will do some reseach on this issue.
I will reply to you ASAP. Thanks for your understanding.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights
 
J

Jeffrey Tan[MSFT]

Hi Barbara,

Thanks for your waiting.
I will ask some colleague of mine who is familiar with Share Point to help
you.
Thanks for your understanding.

Best regards,
Jeffrey Tan
Microsoft Online Partner Support
Get Secure! - www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
R

Rahul Sakdeo

Hi Barbara ,


if you are talking about any of the server controls (like datagrid ) , you
can render the control to a your own HTMLwriter , and grab the HTML out
of it .

Something like :

private void Button1_Click(object sender, System.EventArgs e)
{
//this.Controls.Add(localgrid);
System.IO.StringWriter oSW = new System.IO.StringWriter();
HtmlTextWriter oWriter = new HtmlTextWriter(oSW);
localgrid.RenderControl(oWriter);
Response.Write(oSW.ToString());

}


but if your child control is a webpart , then webpart's don't render their
HTML in RenderControl method , but a RenderWebPart method . You have to
see that which ever webpart you are trying to add allows you to use
RenderWebPart method (cause webpart framework calls that method
approptiatly) ..

In anyways , if you are trying to use the ListView webpart as your child
control , there RenderWebPart method off of that is sealed and you will not
be able to use it . Instead , use the Sharepoint object Model to get to a
list view and then uder the RenderASHTML method off the SPView object to
render a the view as HTML .


Hope this helps.


-Thanks
Rahul Sakdeo
Microsoft Sharepoint Support.
 
G

Guest

----- Rahul Sakdeo (MSFT) wrote: ----

Hi Barbara


if you are talking about any of the server controls (like datagrid ) , you
can render the control to a your own HTMLwriter , and grab the HTML out
of it

Something like

private void Button1_Click(object sender, System.EventArgs e

//this.Controls.Add(localgrid)
System.IO.StringWriter oSW = new System.IO.StringWriter();
HtmlTextWriter oWriter = new HtmlTextWriter(oSW)
localgrid.RenderControl(oWriter)
Response.Write(oSW.ToString())




but if your child control is a webpart , then webpart's don't render their
HTML in RenderControl method , but a RenderWebPart method . You have to
see that which ever webpart you are trying to add allows you to use
RenderWebPart method (cause webpart framework calls that method
approptiatly) .

In anyways , if you are trying to use the ListView webpart as your child
control , there RenderWebPart method off of that is sealed and you will not
be able to use it . Instead , use the Sharepoint object Model to get to a
list view and then uder the RenderASHTML method off the SPView object to
render a the view as HTML


Hope this helps


-Thank
Rahul Sakde
Microsoft Sharepoint Support


I am using Microsoft.SharePoint.Portal.WebControls.ListingSummary as a child control (Microsoft.SharePoint.Portal.WebControls.ListingSummary listSummWP). THis webpart outputs files (portal listings) organized by groups. The output is as simple as a HTML one-column table, with each row representing either the group heading or a filename/file link for each heading.

Can I access this html output so that I can restrict how many files actually display. I was told that since the webparts are sealed and I can't access the code of the webpart, that this would be the easiest way to enhance an existing Microsoft web part since the webpart already does the work of retrieving the files, I just want to access the output of this child webpart and restrict it by doing some hiding with div tags in my webpart and then throw the child away

So far I set up the custom properties in my webpart and pass these values to the child webpart in the override CreateChildControl method. Then in the RenderWebPart method I can output the webpart, this.listSummWP.RenderControl(output). But this is not what I want, I'm not manipulating the html output of the child prior to rendering my webpart. Is one of your examples mentioned above referring to this manipulation?
 
R

Rahul Sakdeo

So far I set up the custom properties in my webpart and pass these values
to the child webpart in the override CreateChildControl method. Then in
the RenderWebPart method I can output the webpart,
this.listSummWP.RenderControl(output). But this is not what I want, I'm
not manipulating the html output of the child prior to rendering my
webpart. Is one of your examples mentioned above referring to this
manipulation?

<rahul sakdeo> In that case you should be able to do something like what
I am doing in my code..


System.IO.StringWriter oSW = new System.IO.StringWriter();
HtmlTextWriter oWriter = new HtmlTextWriter(oSW);
this.listSummWP.RenderControl(oWriter)
string sHTML = oSW.ToString();
//Manipulate sHTML to whatever you want to
output.write(sHTML);

</rahul sakdeo>


Hope this helps.


Rahul Sakdeo
 
G

Guest

Thank-you for the information thus far. It has been very helpful. I had tried something similar but it wasn’t working. Thank-you for the clear example

Referring to your code comment - //Manipulate sHTML to whatever you want to
Now that I have the HTML in a string object, is there an easy way to manipulate the HTML? Is the only way through string manipulation, using String Methods? I've done some work with it so far but the task could prove to be tedious. Before I get to far into it, I wanted to find out if there is an easier way

Thanks
Barbara Alderto

----- Rahul Sakdeo (MSFT) wrote: ----

So far I set up the custom properties in my webpart and pass these values
to the child webpart in the override CreateChildControl method. Then in
the RenderWebPart method I can output the webpart,
this.listSummWP.RenderControl(output). But this is not what I want, I'm
not manipulating the html output of the child prior to rendering my
webpart. Is one of your examples mentioned above referring to this
manipulation

<rahul sakdeo> In that case you should be able to do something like what
I am doing in my code.


System.IO.StringWriter oSW = new System.IO.StringWriter();
HtmlTextWriter oWriter = new HtmlTextWriter(oSW)
this.listSummWP.RenderControl(oWriter
string sHTML = oSW.ToString()
//Manipulate sHTML to whatever you want to
output.write(sHTML)

</rahul sakdeo


Hope this helps


Rahul Sakde
 
S

Scot Rose [MSFT]

Hi Barbara, String manipulation can be tedious at best, but If you have your HTML In a string at this point that is pretty much the only game
in town. What specifically do you want to do with the HTML once you have it in a string?


Scot Rose, MCSD
Microsoft Visual Basic Developer Support
Email : (e-mail address removed) <Remove word online. from address>

This posting is provided “AS IS”, with no warranties, and confers no rights.

Get Secure!
http://www.microsoft.com/security
http://www.microsoft.com/protect


--------------------
Thread-Topic: Child WebParts in SPS 2003
thread-index: AcPh/+RTiDkeuv1TQS2KAHIqSjHgDQ==
X-Tomcat-NG: microsoft.public.dotnet.languages.csharp
From: "=?Utf-8?B?QmFyYmFyYSBBbGRlcnRvbg==?=" <[email protected]>
References: <[email protected]> <[email protected]> <46BBF89F-174B-49FB-
Subject: RE: Child WebParts in SPS 2003
Date: Fri, 23 Jan 2004 14:26:06 -0800
Lines: 39
Message-ID: <[email protected]>
MIME-Version: 1.0
Content-Type: text/plain;
charset="Utf-8"
Content-Transfer-Encoding: 8bit
X-Newsreader: Microsoft CDO for Windows 2000
Content-Class: urn:content-classes:message
Importance: normal
Priority: normal
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
Newsgroups: microsoft.public.dotnet.languages.csharp
Path: cpmsftngxa07.phx.gbl
Xref: cpmsftngxa07.phx.gbl microsoft.public.dotnet.languages.csharp:214755
NNTP-Posting-Host: tk2msftcmty1.phx.gbl 10.40.1.180
X-Tomcat-NG: microsoft.public.dotnet.languages.csharp

Thank-you for the information thus far. It has been very helpful. I had tried something similar but it wasn’t working. Thank-you for the
clear example.



Referring to your code comment - //Manipulate sHTML to whatever you want to

Now that I have the HTML in a string object, is there an easy way to manipulate the HTML? Is the only way through string manipulation,
using String Methods? I've done some work with it so far but the task could prove to be tedious. Before I get to far into it, I wanted to find
out if there is an easier way?



Thanks,

Barbara Alderton



----- Rahul Sakdeo (MSFT) wrote: -----



So far I set up the custom properties in my webpart and pass these values

to the child webpart in the override CreateChildControl method. Then in

the RenderWebPart method I can output the webpart,

this.listSummWP.RenderControl(output). But this is not what I want, I'm

not manipulating the html output of the child prior to rendering my

webpart. Is one of your examples mentioned above referring to this

manipulation?



<rahul sakdeo> In that case you should be able to do something like what

I am doing in my code..





System.IO.StringWriter oSW = new System.IO.StringWriter();

HtmlTextWriter oWriter = new HtmlTextWriter(oSW);

this.listSummWP.RenderControl(oWriter)

string sHTML = oSW.ToString();

//Manipulate sHTML to whatever you want to

output.write(sHTML);



</rahul sakdeo>





Hope this helps.





Rahul Sakdeo
 
G

Guest

Background
I need to enhance the functionality of the Group Listing (Listing Summary) webpart. Since this Microsoft webpart is sealed, I was given the following design suggestion. Define the existing webpart as a child webpart (custom control) of the new custom webpart. Use the output from the child webpart (HTML) and manipulate it to be how I want it and then render the new HTML to the page

I need to do two things. One, add a button/link after each document listing, which allows the user to get a pop-up box giving the document details such as author, creation date, etc. Second, I need traverse through the table output (html) and restrict the output of each group listing to a site administator's defined value. I need to hide the rest of the items in the group that exceed this amount in a hidden div tag. I will then have a link at the end of each grioup listing section which allows the user to unhide the items in this hidden tag

I was told manipulating this child parts HTML output would be easier than recreating all the other functionality of the Listing Summary webpart. So far I have found no examples of using webparts as a child webpart, just examples of using other controls(textbox, buttons, etc.) as child controls

----- Scot Rose [MSFT] wrote: ----

Hi Barbara, String manipulation can be tedious at best, but If you have your HTML In a string at this point that is pretty much the only game
in town. What specifically do you want to do with the HTML once you have it in a string?


Scot Rose, MCS
Microsoft Visual Basic Developer Suppor
Email : (e-mail address removed) <Remove word online. from address

This posting is provided “AS ISâ€, with no warranties, and confers no rights

Get Secure
http://www.microsoft.com/securit
http://www.microsoft.com/protec


-------------------
Thread-Topic: Child WebParts in SPS 200
thread-index: AcPh/+RTiDkeuv1TQS2KAHIqSjHgDQ=
X-Tomcat-NG: microsoft.public.dotnet.languages.cshar
From: "=?Utf-8?B?QmFyYmFyYSBBbGRlcnRvbg==?=" <[email protected]>>References: <[email protected]><[email protected]><46BBF89F-174B-49FB
[email][email protected]> said:
Date: Fri, 23 Jan 2004 14:26:06 -080
Lines: 3
Message-ID: <[email protected]>>MIME-Version: 1.
Content-Type: text/plain
charset="Utf-8
Content-Transfer-Encoding: 8bi
X-Newsreader: Microsoft CDO for Windows 200
Content-Class: urn:content-classes:messag
Importance: norma
Priority: norma
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.
Newsgroups: microsoft.public.dotnet.languages.cshar
Path: cpmsftngxa07.phx.gb
Xref: cpmsftngxa07.phx.gbl microsoft.public.dotnet.languages.csharp:21475
NNTP-Posting-Host: tk2msftcmty1.phx.gbl 10.40.1.18
X-Tomcat-NG: microsoft.public.dotnet.languages.cshar
Thank-you for the information thus far. It has been very helpful. I had tried something similar but it wasn’t working. Thank-you for the
clear example



Referring to your code comment - //Manipulate sHTML to whatever you want to

Now that I have the HTML in a string object, is there an easy way to manipulate the HTML? Is the only way through string manipulation,
using String Methods? I've done some work with it so far but the task could prove to be tedious. Before I get to far into it, I wanted to find
out if there is an easier way



Thanks

Barbara Alderto



----- Rahul Sakdeo (MSFT) wrote: ----



So far I set up the custom properties in my webpart and pass these values

to the child webpart in the override CreateChildControl method. Then in

the RenderWebPart method I can output the webpart,

this.listSummWP.RenderControl(output). But this is not what I want, I'm

not manipulating the html output of the child prior to rendering my

webpart. Is one of your examples mentioned above referring to this

manipulation?



<rahul sakdeo> In that case you should be able to do something like what

I am doing in my code..





System.IO.StringWriter oSW = new System.IO.StringWriter();

HtmlTextWriter oWriter = new HtmlTextWriter(oSW);

this.listSummWP.RenderControl(oWriter)

string sHTML = oSW.ToString();

//Manipulate sHTML to whatever you want to

output.write(sHTML);



</rahul sakdeo>





Hope this helps.





Rahul Sakdeo
 
S

Scot Rose [MSFT]

You may be able to use the Writeline method of the object. The only Documentation we have is on the MSDN web site

http://msdn.microsoft.com/library/d.../frlrfsystemwebuihtmltextwriterclasstopic.asp



Scot Rose, MCSD
Microsoft Visual Basic Developer Support
Email : (e-mail address removed) <Remove word online. from address>

This posting is provided “AS IS”, with no warranties, and confers no rights.

Get Secure!
http://www.microsoft.com/security
http://www.microsoft.com/protect


--------------------
Thread-Topic: Child WebParts in SPS 2003
thread-index: AcPl2Xgz9Szke8fOQLClXUHGqXkwHQ==
X-Tomcat-NG: microsoft.public.dotnet.languages.csharp
From: "=?Utf-8?B?QmFyYmFyZSBBbGRlcnRvbg==?=" <[email protected]>
References: <[email protected]> <[email protected]> <46BBF89F-174B-49FB-
Subject: RE: Child WebParts in SPS 2003
Date: Wed, 28 Jan 2004 12:01:08 -0800
Lines: 133
Message-ID: <[email protected]>
MIME-Version: 1.0
Content-Type: text/plain;
charset="Utf-8"
Content-Transfer-Encoding: 8bit
X-Newsreader: Microsoft CDO for Windows 2000
Content-Class: urn:content-classes:message
Importance: normal
Priority: normal
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
Newsgroups: microsoft.public.dotnet.languages.csharp
Path: cpmsftngxa07.phx.gbl
Xref: cpmsftngxa07.phx.gbl microsoft.public.dotnet.languages.csharp:216103
NNTP-Posting-Host: tk2msftcmty1.phx.gbl 10.40.1.180
X-Tomcat-NG: microsoft.public.dotnet.languages.csharp

Instead of manipulating the HTML string, can't I manipulate the HTMLTextWriter object prior to assignning it to text by using the
HTMLTextWriter methods? If so do you have any documentation or examples of using this technique



Bar



----- Barbara Alderton wrote: ----



Background

I need to enhance the functionality of the Group Listing (Listing Summary) webpart. Since this Microsoft webpart is sealed, I was given
the following design suggestion. Define the existing webpart as a child webpart (custom control) of the new custom webpart. Use the
output from the child webpart (HTML) and manipulate it to be how I want it and then render the new HTML to the page



I need to do two things. One, add a button/link after each document listing, which allows the user to get a pop-up box giving the
document details such as author, creation date, etc. Second, I need traverse through the table output (html) and restrict the output of each
group listing to a site administator's defined value. I need to hide the rest of the items in the group that exceed this amount in a hidden div
tag. I will then have a link at the end of each grioup listing section which allows the user to unhide the items in this hidden tag



I was told manipulating this child parts HTML output would be easier than recreating all the other functionality of the Listing Summary
webpart. So far I have found no examples of using webparts as a child webpart, just examples of using other controls(textbox, buttons,
etc.) as child controls



----- Scot Rose [MSFT] wrote: ----



Hi Barbara, String manipulation can be tedious at best, but If you have your HTML In a string at this point that is pretty much the only
game

in town. What specifically do you want to do with the HTML once you have it in a string?





Scot Rose, MCS

Microsoft Visual Basic Developer Suppor

Email : (e-mail address removed) <Remove word online. from address



This posting is provided “AS ISâ€, with no warranties, and confers no rights



Get Secure!

http://www.microsoft.com/security

http://www.microsoft.com/protect





--------------------
Thread-Topic: Child WebParts in SPS 2003
thread-index: AcPh/+RTiDkeuv1TQS2KAHIqSjHgDQ==
X-Tomcat-NG: microsoft.public.dotnet.languages.csharp
From: "=?Utf-8?B?QmFyYmFyYSBBbGRlcnRvbg==?=" <[email protected]>>References: <0c6901c3db8c
[email protected]><[email protected]><46BBF89F-174B-49FB-

[email][email protected]> said:
Date: Fri, 23 Jan 2004 14:26:06 -0800
Lines: 39
Message-ID: <[email protected]>>MIME-Version: 1.0
Content-Type: text/plain;

Content-Transfer-Encoding: 8bit
X-Newsreader: Microsoft CDO for Windows 2000
Content-Class: urn:content-classes:message
Importance: normal
Priority: normal
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
Newsgroups: microsoft.public.dotnet.languages.csharp
Path: cpmsftngxa07.phx.gbl
Xref: cpmsftngxa07.phx.gbl microsoft.public.dotnet.languages.csharp:214755
NNTP-Posting-Host: tk2msftcmty1.phx.gbl 10.40.1.180
X-Tomcat-NG: microsoft.public.dotnet.languages.csharp
you for the

clear example.







Referring to your code comment - //Manipulate sHTML to whatever you want to



Now that I have the HTML in a string object, is there an easy way to manipulate the HTML? Is the only way through string
manipulation,

using String Methods? I've done some work with it so far but the task could prove to be tedious. Before I get to far into it, I wanted to
find

out if there is an easier way?







Thanks,



Barbara Alderton







----- Rahul Sakdeo (MSFT) wrote: -----







So far I set up the custom properties in my webpart and pass these values



to the child webpart in the override CreateChildControl method. Then in



the RenderWebPart method I can output the webpart,



this.listSummWP.RenderControl(output). But this is not what I want, I'm



not manipulating the html output of the child prior to rendering my



webpart. Is one of your examples mentioned above referring to this



manipulation?







<rahul sakdeo> In that case you should be able to do something like what



I am doing in my code..











System.IO.StringWriter oSW = new System.IO.StringWriter();



HtmlTextWriter oWriter = new HtmlTextWriter(oSW);



this.listSummWP.RenderControl(oWriter)



string sHTML = oSW.ToString();



//Manipulate sHTML to whatever you want to



output.write(sHTML);







</rahul sakdeo>











Hope this helps.











Rahul Sakdeo
 
G

Guest

Hi, Barb

Scot is out today and asked me to follow up with his active threads.

Did the link that Scot provided on Monday resolve your issue, or is there
more that needs to be done?

Please respond so that we know where things stand.

Thank you for choosing the MSDN Managed Newsgroups,

John Eikanger
Microsoft Developer Support

This posting is provided “AS IS” with no warranties, and confers no rights.
--------------------
| From: (e-mail address removed) (Scot Rose [MSFT])
| Organization: Microsoft
| Date: Mon, 02 Feb 2004 15:13:14 GMT
| Subject: RE: Child WebParts in SPS 2003
| Newsgroups: microsoft.public.dotnet.languages.csharp
| Lines: 208
| Path: cpmsftngxa07.phx.gbl
| Xref: cpmsftngxa07.phx.gbl microsoft.public.dotnet.languages.csharp:217407
| NNTP-Posting-Host: tomcatimport2.phx.gbl 10.201.218.182
|
| You may be able to use the Writeline method of the object. The only
Documentation we have is on the MSDN web site
|
|
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/
frlrfsystemwebuihtmltextwriterclasstopic.asp
|
|
|
| Scot Rose, MCSD
| Microsoft Visual Basic Developer Support
| Email : (e-mail address removed) <Remove word online. from address>
|
| This posting is provided “AS IS”, with no warranties, and confers no
rights.
|
| Get Secure!
| http://www.microsoft.com/security
| http://www.microsoft.com/protect
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top