some of you maybe get used of using Web Part extension in Visual Studio Project and build the UI using code without the UI there but i found a simple alternative using User Control and in the Web Part is just some code to load that UserControl. U can debug ur code and it's with UI :D
here is what i'm doing..
User Control Project:
1. Create New ASP.NET Web Application.
2. Add New User Control into the Project.
3. Design your User Control, u can add code behind or anything like that.
4. Test the User Control by dragging it to Default.aspx page that automatically created from step 1.
5. Build your Application for the last time (it will have .dll inside bin folder of your application).
for now we leave the User Control Project, we go on making our Web Part Object
1. Create New Web Part Project,
2. You can delete the default Webpart project that created then create new one to suit the name or u can use the existing one.
that's all
see u
here is what i'm doing..
User Control Project:
1. Create New ASP.NET Web Application.
2. Add New User Control into the Project.
3. Design your User Control, u can add code behind or anything like that.
4. Test the User Control by dragging it to Default.aspx page that automatically created from step 1.
5. Build your Application for the last time (it will have .dll inside bin folder of your application).
for now we leave the User Control Project, we go on making our Web Part Object
1. Create New Web Part Project,
2. You can delete the default Webpart project that created then create new one to suit the name or u can use the existing one.
3. Add reference to Microsoft.Sharepoint.dll
4. Add some directive
5. Add this variable UserControl userControl; (u can use anything u want)
6. Add this line of code to your CreateChildControls method
7. Add this line to your Render method
8. Build the Web Part Project.
4. Add some directive
5. Add this variable UserControl userControl; (u can use anything u want)
6. Add this line of code to your CreateChildControls method
userControl = (UserControl)Page.LoadControl(@"/_controltemplates/your_user_control_file_here.ascx");
this.Controls.Add(userControl);
7. Add this line to your Render method
userControl.RenderControl(writer);
8. Build the Web Part Project.
here is the tricky part:
1. Copy the .dll from both project (Web Part and User Control) to your virtual directory bin folder.
2. Edit web.config so it's Full trust
3. Copy the .ascx to ControlTemplate directory that is under C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\TEMPLATE\CONTROLTEMPLATES in my Computer
4. do IIS reset
5. Add the WebPart in your MOSS / WSS Site and add them to the page
u can see the User Control now right?
in case any changes u made with User Control, just make sure to copy back the newly .dll to the bin folder and the .ascx to CONTROLTEMPLATE directory
PS: no need to GAC it..for the security, i think it's gonna be a problem if u want tight security because all the .dll is assume to be safe??? never explore it, if anyone have a comment about this..please share it
that's all
see u
Comments