I'm new at developing an web part with Visual Studio. I want a weather web part. I created an empty SP 2013 Project, added Web Part item. But when I deploy it and add the custom webpart into my site. It gives an error:
Sorry, something went wrong An unexpected error has occurred.
Web Parts Maintenance Page: If you have permission, you can use this page to temporarily close Web Parts or remove personal settings. For more information, contact your site administrator.
I deleted the webpart and add again. Nothing changed. What else should I have to do? Thank you.
My WebPart item name : HavaDurumuWP My Project name: HavaDurumu
Elements.xml:
<?xml version="1.0" encoding="utf-8"?>
<Elements xmlns="http://schemas.microsoft.com/sharepoint/" >
<Module Name="HavaDurumuWP" List="113" Url="_catalogs/wp">
<File Path="HavaDurumuWP\HavaDurumuWP.webpart" Url="HavaDurumuWP_HavaDurumuWP.webpart" Type="GhostableInLibrary">
<Property Name="Group" Value="Custom" />
</File>
</Module>
</Elements>
Here is my HavaDurumuWP.cs:
namespace HavaDurumuWP.HavaDurumuWP
{
[ToolboxItemAttribute(false)]
public class HavaDurumuWP : WebPart
{
public void client_DownloadStringCompleted(object sender, DownloadStringCompletedEventArgs e)
{
if (!e.Cancelled && e.Error == null)
{
string res = Convert.ToString(e.Result);
HtmlAgilityPack.HtmlDocument doc = new HtmlAgilityPack.HtmlDocument();
doc.LoadHtml(res);
var table = doc.DocumentNode.SelectSingleNode("//table[@class='tbl_sond']");
var degree = table.SelectSingleNode("//td[@class='renkMax']");
var date = table.SelectSingleNode("//td[@class='sond_zaman']");
}
LiteralControl filterMessage = new LiteralControl("ece");
this.Controls.Add(filterMessage);
}
protected override void CreateChildControls()
{
string url = "http://www.mgm.gov.tr/tahmin/il-ve-ilceler.aspx?m=ISTANBUL";
WebClient webclient = new WebClient();
webclient.DownloadStringCompleted += new DownloadStringCompletedEventHandler(client_DownloadStringCompleted);
Uri uri = new Uri(url);
webclient.DownloadStringAsync(uri);
}
}
}