Sharepoint WebPart

Last post 05-11-2008 11:28 AM by DigiMortal. 6 replies.

Sort Posts:

  • Sharepoint WebPart

    05-10-2008, 10:13 PM
    • Loading...
    • simonDev
    • Joined on 05-11-2008, 1:36 AM
    • Posts 2

     

    I was wondering how could I develop web parts using the ASP.NET wysiwyg or the Design Mode.
    I read a lot about how to create web parts and most of the tutorials say that I have to create a Visual C# project with Class Library as template.

    Then, I have to inherit from WebPart and override methods.

    The problem is that I don't understand why I would add my different controls in that C# file by typing them.

    For example :

       tbA = new TextBox();
       btnX = new Button();

    Wouldn't it be easier to use an .aspx file and add them in Design mode ?

    Is it possible ? and can anyone point me to the right direction on how to do it

    I know that using SmartPart with aspx file works, but I want to create my own WebParts. 


     




     

     

  • Re: Sharepoint WebPart

    05-11-2008, 4:39 AM
    • Loading...
    • DigiMortal
    • Joined on 01-10-2007, 7:22 PM
    • Tallinn, Estonia
    • Posts 305
    Check out SmartPart project from CodePlex.
    Don't forget to mark solution providing post as "Answered".
    It helps others to find correct solutions!

    Also visit my ASP.NET blog!
  • Re: Sharepoint WebPart

    05-11-2008, 4:54 AM
    Answer
    • Loading...
    • madhur25
    • Joined on 01-10-2008, 3:20 AM
    • Bangalore
    • Posts 53
    Webparts do not have an UI file (.ascx of .aspx) associated with them.
    A webpart by definition is a single class derived from WebPart class, which
    can be rendered solely calling Render function of that class.

    So the only way of designing UI is through code.

    Alternatively, as you said, you can use Create UserControls and host them in
    SmartPart.

    --
    Madhur

    "simonDev" wrote in message news:2350183@forums.asp.net...
    >I was wondering how could I develop web parts using the ASP.NET wysiwyg or
    >the Design Mode.
    > I read a lot about how to create web parts and most of the tutorials say
    > that I have to create a Visual C# project with Class Library as template.
    >
    > Then, I have to inherit from WebPart and override methods.
    >
    > The problem is that I don't understand why I would add my different
    > controls in that C# file by typing them.
    >
    > For example :
    >
    > tbA = new TextBox();
    > btnX = new Button();
    >
    > Wouldn't it be easier to use an .aspx file and add them in Design mode ?
    >
    > Is it possible ? and can anyone point me to the right direction on how to
    > do it
    >
    > I know that using SmartPart with aspx file works, but I want to create my
    > own WebParts.
    >
    Madhur Ahuja

    http://madhurahuja.blogspot.com
  • Re: Sharepoint WebPart

    05-11-2008, 6:12 AM
    • Loading...
    • DigiMortal
    • Joined on 01-10-2007, 7:22 PM
    • Tallinn, Estonia
    • Posts 305
    By default, web parts doesn't have UI containers like ASCX. You are always free to write web parts that use ASCX files :)
    Don't forget to mark solution providing post as "Answered".
    It helps others to find correct solutions!

    Also visit my ASP.NET blog!
  • Re: Sharepoint WebPart

    05-11-2008, 9:48 AM
    • Loading...
    • madhur25
    • Joined on 01-10-2008, 3:20 AM
    • Bangalore
    • Posts 53
    That would be same as using SmartPart. At the end you would be using
    LoadControl function.

    "DigiMortal" wrote in message news:2350452@forums.asp.net...
    > By default, web parts doesn't have UI containers like ASCX. You are always
    > free to write web parts that use ASCX files :)
    >
    Madhur Ahuja

    http://madhurahuja.blogspot.com
  • Re: Sharepoint WebPart

    05-11-2008, 11:19 AM
    • Loading...
    • simonDev
    • Joined on 05-11-2008, 1:36 AM
    • Posts 2

     Thanks a lot for the answers.

    I think I'm gonna do it the long and hard way :)
     

  • Re: Sharepoint WebPart

    05-11-2008, 11:28 AM
    • Loading...
    • DigiMortal
    • Joined on 01-10-2007, 7:22 PM
    • Tallinn, Estonia
    • Posts 305
    Well, the hard way is somehow better because you don't have to worry about templates when deploying your solution. Your web part is one class that offers its functionality and that's it.
    Don't forget to mark solution providing post as "Answered".
    It helps others to find correct solutions!

    Also visit my ASP.NET blog!
Page 1 of 1 (7 items)