SharePoint - visual web part problems - Asked By Bookworm on 10-Jan-12 10:38 AM

Hi,
i have 2 visual web part in a project, and i insert them to 2 different pages
everything works fine during the debug
but when i open as a simple user, the pages are blank, and when i try to rienter the visual web parts one message shows, : you cannot insert it because it is deleted.......
i dont know what is this, sometimes everything looks fine

any idea?

thnx
[)ia6l0 iii replied to Bookworm on 10-Jan-12 10:55 AM
Answer these Q's:

a) Do the visual web parts inherit from the UserControl class? 
b) And what do you do on the OnLoad event of the visual web part?
c) How did you Register the visual web part on the page?
Bookworm replied to [)ia6l0 iii on 10-Jan-12 11:02 AM
a) the code i wrote in the usercontrol where is even the load event
b) in the load event i just bind the grid
c)i inserted a web part after editing the page, and go to the custom where are all my visual web parts that i created.

thnx
D Company replied to Bookworm on 10-Jan-12 11:04 AM
Hello Friend,

As you discussed the issue it seems strange behavior(when you say sometimes everything looks fine)

to fix this issue

try debugging the visual web part while attaching it in your page

here is link how to debug webparts follow the steps

http://www.eggheadcafe.com/community/sharepoint/69/10345200/how-to-debug-visual-webpart-for-sharepoint-2010-in-visual-studio-2010.aspx

let us know in case , if you dont get any pointer

Regards
D
Bookworm replied to D Company on 10-Jan-12 11:10 AM
during the debbuging everything is perfect:(((((

i dont know what happen sometimes, is the first time looking this problem:(((((

thnx a lot
kalpana aparnathi replied to Bookworm on 10-Jan-12 02:45 PM

Debugging the Web Part

Let’s test this so far. Set the LowInventoryWebPart project as the startup project of your solution (if it isn’t already) and set a breakpoint on the LINQ query. Hit F5 and Visual Studio will recycle the IIS worker process, package & deploy & activate the feature, and attach the debugger automatically for you. This is shown in the Output window and it’s fun to watch so you may want to pin that window open. :-)

------ Deploy started: Project: LowInventoryWebPart, Configuration: Debug Any CPU ------ 
Active Deployment Configuration: Default
Run Pre-Deployment Command:
  Skipping deployment step because a pre-deployment command is not specified.
Recycle IIS Application Pool:
  Skipping application pool recycle because no matching package on the server was found.
Retract Solution:
  Skipping package retraction because no matching package on the server was found.
Add Solution:
  Adding solution 'LowInventoryWebPart.wsp'...
  Deploying solution 'LowInventoryWebPart.wsp'...
Activate Features:
  Activating feature 'Feature1' ...
Run Post-Deployment Command:
  Skipping deployment step because a post-deployment command is not specified.
========== Build: 1 succeeded or up-to-date, 0 failed, 0 skipped ==========
========== Deploy: 1 succeeded, 0 failed, 0 skipped ==========

The nice thing is that Visual Studio handles all the deployment as well as all the cleanup. When you close the debugger the feature is deactivated and the package is retracted and deleted. Notice that you can also specify pre and post deployment commands, plus a whole lot more. The Feature and Package designers are very flexible. (For more information watch this Channel 9 Interview: SharePoint Feature and Package Designers in Visual Studio 2010 and read Packaging and Deploying SharePoint Solutions in the MSDN library.)

In order to debug this sucker we first have to add it to a page on our site. When the debugger starts up, it opens a page to the site we specified in the SharePoint Customization Wizard in the beginning. So select Site Actions in the upper left, then Edit Page. Select the Insert tab on the Ribbon and click Web Part. Select the Custom category and you should see your web part. Select it and click Add on the bottom right of the section.

image

At this point you should hit your breakpoint. Hit F11 and the query will return the low inventory so you can see the data as you design the page. The Page_Load will get called a couple times when designing the web part so keep that in mind.

Next drop down the LowInventoryWebPart menu at the top right of the web part and select Edit Web Part to open the properties. Set the Title to “Low Inventory” and click OK. On the Page tab on the Ribbon select Save to save and close the page editor. Now we’ve got a nice looking web part for browsing low inventory. Sweet!

image

Close the browser window and this will close your debugging session, recycle the IIS app pool, deactivate the feature and retract the solution automatically for you. These steps are also displayed in the Output window.