input string was not in a correct format, lookup additional column

Problem: I have a list, which have a Lookup(Venue)+additional column as ID(“Venue:ID”) you can see in the above picture, when i try to get the value of the “Venue:ID” and convert into int32 through my code, it gives me an error input string was not in a correct format,

To mistake i was making is that, lookup always bring value like some this “2;#2”;

so you can use the split method to get the id or use LookUp properties.

 

Advertisements

Attempted to use an object that has ceased to exist. (Exception from HRESULT: 0x80030102 (STG_E_REVERTED))

Attempted to use an object that has ceased to exist. (Exception from HRESULT: 0x80030102 (STG_E_REVERTED))


When working with visual webpart control, my visual webpart works fine, but when i deploy the more then one Visual webpart on a single page, it gives me above error, while going in to many forums and reading the blogs, i was wondering there is some thing with my code and the SPSite and SPWeb object disposal.

i used to write the code like this

using (SPSite site =SPContext.Current.Site)
{

using (SPWeb web = site.RootWeb)
{

// your code

}

}

though i am scoping the object rightly(using automatically dispose the object the routine gets outside the scope), but there is still some thing missing, after some time i figured out that the problem is with SPContext object rather than SPsite object, because once it dispose in one Visual Webpart, it can not be acquired back, so i change the code like this

using (SPSite site = new SPSite(SPContext.Current.Site.Url))
{

using (SPWeb web = site.RootWeb)
{

// your code

}

}

and do use the using scope, it will save you from explicitly disposing the objects 😀

using (SPSite site = new SPSite(SPContext.Current.Site.Url))

using (SPWeb web = site.RootWeb)
{

The Security validation for this page is invalid.Click back in your web browser, refresh the page, and try your operation again

If you are experiening this error “The Security validation for this page is invalid.Click back in your web browser, refresh the page, and try your operation again” , even though you have impersonate user as System Account.

No problem, you got to tell the web application that you will be doing some impersonate tricks inside your code. To do this

go to the Central Administration site–> Under Application management, Click Manage web application.

Select the web application you are working on, in the ribbon Click General Settings, scroll down to see the  Web Page Security Validation, turn off the Security validation–> save the settings.

 



The error has gone now 🙂

Three R’s for SharePoint Developer

To all the SharePoint developers

Due to our least interest in Administration of SharePoint. The three R’s holds the key for making our head save from banging into the wall.

1. Recycle App pool: Needs to do more often then pressing f5 key for the browser.

2. Reset IIS: If Recycle doesn’t work as it suppose to do, restart the IIS.

3.Restart the machine: If the problem persist, and your server is behaving like a mad cow :), Restart the machine

 

Hopes that it will work in  your case  as well

 

 

Error: This page contains content or formatting that is not valid. You can find more information in the affected sections. Important StatusPublication Start Date: Immediately Important StatusStatus: Checked out and editable.

working with validation controls in the visual webpart, an error arise when you place the webpart on to the page, actually on the edit mode SharePoint doesn’t allow the validation controls.

To do the code gig,go to webpart class file and

protected override void CreateChildControls()        {

 

//added piece of code

WebPartManager wp = WebPartManager.GetCurrentWebPartManager(this.Page);

if (wp.DisplayMode == WebPartManager.BrowseDisplayMode)

//piece of code ended

{

base.CreateChildControls();

Control control = Page.LoadControl(_ascxPath);

Controls.Add(control);

}

}