Archive

Archive for the ‘ASP.NET’ Category

Unable to find manifest signing certificate in the certificate store

September 11, 2014 Leave a comment

Hi All,

Today after getting latest for my project from Team Foundation Server I was not able to build the solution as the mentioned above error was appearing. After doing some googling finally I found a link which resolved my problem. If this is the case with you then just remove the following from your .csproj file.

<PropertyGroup>

<ManifestCertificateThumbprint>…………</ManifestCertificateThumbprint>

</PropertyGroup>

<PropertyGroup>

<ManifestKeyFile>xxxxxxxx.pfx</ManifestKeyFile>

</PropertyGroup>

<PropertyGroup>

<GenerateManifests>true</GenerateManifests>

</PropertyGroup>

<PropertyGroup>

<SignManifests>false</SignManifests>

</PropertyGroup>

 

After doing so it resolved my issue J.

Reff: stackoverflow.

Regards.

 

Exporting Web / App parts (Content Editor, App, and Visual Web Part).

August 21, 2013 3 comments

I would not be wrong if i call web part as vital part of SharePoint. Today we will be discussing to export and use the exported web parts in Visual Studio.

  • Web part.
  • Content Editor Web part.
  • App 2013 (List view web part).

So let’s get started, but before doing things we need to make sure following this are also properly settled.

  • Export Mode from ‘Edit Web part’ Options should have ‘Export all Data’. Through this we will be able to export the web part and that will be exported as .dwp  or .wp
  • If not set before then set ‘Export all data’ and apply/ok.

Web Part:

  • Select Edit Page option then select Edit Web part from the web part zone on which your required web part is placed.
  • Select ‘Export’ Option.
  • On selecting ‘Export’, dialogue to save the web part will open, save it to you required destination.


  • Open that file with Note Pad or Note Pad ++.
  • On opening you would have the following

    <webParts>

    <webPart xmlns=”http://schemas.microsoft.com/WebPart/v3″&gt;

    <metaData>

    <type name=”xxxxxxxxxxxxxxxxxxxxxxx, xxxxxxxxxxxxx, Version=1.0.0.0, Culture=neutral, PublicKeyToken=xxxxxxxxxxxxx” />

    <importErrorMessage>Cannot import this Web Part.</importErrorMessage>

    </metaData>

    <data>

    <properties>

    <property name=”numberOfItemsToDisplay” type=”int”>10</property>

    <property name=”ExportMode” type=”exportmode”>All</property>

    <property name=”HelpUrl” type=”string” />

    <property name=”Hidden” type=”bool”>False</property>

    <property name=”Description” type=”string”>My Visual Web Part</property>

    <property name=”CatalogIconImageUrl” type=”string” />

    <property name=”Title” type=”string”>Custom Webpart</property>

    <property name=”AllowHide” type=”bool”>True</property>

    <property name=”AllowMinimize” type=”bool”>True</property>

    <property name=”AllowZoneChange” type=”bool”>True</property>

    <property name=”TitleUrl” type=”string” />

    <property name=”ChromeType” type=”chrometype”>None</property>

    <property name=”AllowConnect” type=”bool”>True</property>

    <property name=”Width” type=”unit” />

    <property name=”Height” type=”unit” />

    <property name=”HelpMode” type=”helpmode”>Navigate</property>

    <property name=”AllowEdit” type=”bool”>True</property>

    <property name=”TitleIconImageUrl” type=”string” />

    <property name=”Direction” type=”direction”>NotSet</property>

    <property name=”SharePointWebURL” type=”string” null=”true” />

    <property name=”AllowClose” type=”bool”>True</property>

    <property name=”ChromeState” type=”chromestate”>Normal</property>

    </properties>

    </data>

    </webPart>

    </webParts>

  • Copy all from <webParts> … </webParts>, in nutshell copy all.
  • That is your required xml which is to be added in Visual studio under web part zone in

    <AllUsersWebPart
    WebPartZoneID=xc…
    WebPartOrder=1>

    <![CDATA[

    ‘Your Copied XML’
    ]]>

    </AllUsersWebPart>

    Content Editor:

Exporting web part is same for all, there are some tweaks to do in Content Editor Web part’s exported XML. So let’s jump to it. Content Editor Web part’s exported xml would look like the following

<?xml version=”1.0″ encoding=”utf-8″?>

<WebPart xmlns:xsd=”http://www.w3.org/2001/XMLSchema&#8221; xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance&#8221; xmlns=”http://schemas.microsoft.com/WebPart/v2″&gt;

<Title>Content Editor</Title>

<FrameType>None</FrameType>

<Description>Allows authors to enter rich text content.</Description>

<IsIncluded>true</IsIncluded>

<ZoneID>x917ee352abe847918eefcb35fd02bf0f</ZoneID>

<PartOrder>0</PartOrder>

<FrameState>Normal</FrameState>

<Height />

<Width />

<AllowRemove>true</AllowRemove>

<AllowZoneChange>true</AllowZoneChange>

<AllowMinimize>true</AllowMinimize>

<AllowConnect>true</AllowConnect>

<AllowEdit>true</AllowEdit>

<AllowHide>true</AllowHide>

<IsVisible>true</IsVisible>

<DetailLink />

<HelpLink />

<HelpMode>Modeless</HelpMode>

<Dir>Default</Dir>

<PartImageSmall />

<MissingAssembly>Cannot import this Web Part.</MissingAssembly>

<PartImageLarge>/_layouts/15/images/mscontl.gif</PartImageLarge>

<IsIncludedFilter />

<Assembly>Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c</Assembly>

<TypeName>Microsoft.SharePoint.WebPartPages.ContentEditorWebPart</TypeName>

<ContentLink xmlns=”http://schemas.microsoft.com/WebPart/v2/ContentEditor&#8221; />


<Content xmlns=”http://schemas.microsoft.com/WebPart/v2/ContentEditor”&gt;<![CDATA[<div class=”block”>

<h3>Related Pages</h3>

<div class=”rlinks”>

<ul>

<li>

<a href=”/Pages/ABC.aspx”> ABC</a></li>

</ul>

</div>

</div>

<div class=”block”>

<h3>By Telephone </h3>

<div class=”rlinks”>

<ul>

<li>Tel : +92 336 335 334 6</li>

<li>Fax : +92 336 335 334 6</li>

</ul>

</div>

</div>

<div class=”block”>

<h3>

<a href=”#”>By Email </a></h3>

<div class=”rlinks”>

<ul>

<li>

<a href=”#”> ABC @ ABC.com</a></li>

</ul>

</div>

</div> ]]></Content>

<PartStorage xmlns=”http://schemas.microsoft.com/WebPart/v2/ContentEditor&#8221; />

</WebPart>

  • Everything added in content editor would come under <Content> tag.
  • You will notice there is already <![CDATA[ tag into it, Change this Tad to <Value> and its closing ]]> to </Value> too.
  • Moreover Copy all the text between <![CDATA[ and its closing ]]> highlighted.
  • Content editor web part needs encoded HTML so we need to encode it. This can be encoded from HTML Encode.
  • Paste all the encoded HTML between <Value> encoded HTML </Value>.
  • The final exported web part XML should look like

     

    <? xml version=”1.0″ encoding=”utf-8″?>

    <WebPart xmlns:xsd=”http://www.w3.org/2001/XMLSchema&#8221; xmlns:xsi=”http://www.w3.org/2001/XMLSchema-instance&#8221; xmlns=”http://schemas.microsoft.com/WebPart/v2″&gt;

    <Title>Content Editor</Title>

    <FrameType>None</FrameType>

    <Description>Allows authors to enter rich text content.</Description>

    <IsIncluded>true</IsIncluded>

    <ZoneID>x917ee352abe847918eefcb35fd02bf0f</ZoneID>

    <PartOrder>0</PartOrder>

    <FrameState>Normal</FrameState>

    <Height />

    <Width />

    <AllowRemove>true</AllowRemove>

    <AllowZoneChange>true</AllowZoneChange>

    <AllowMinimize>true</AllowMinimize>

    <AllowConnect>true</AllowConnect>

    <AllowEdit>true</AllowEdit>

    <AllowHide>true</AllowHide>

    <IsVisible>true</IsVisible>

    <DetailLink />

    <HelpLink />

    <HelpMode>Modeless</HelpMode>

    <Dir>Default</Dir>

    <PartImageSmall />

    <MissingAssembly>Cannot import this Web Part.</MissingAssembly>

    <PartImageLarge>/_layouts/15/images/mscontl.gif</PartImageLarge>

    <IsIncludedFilter />

    <Assembly>Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c</Assembly>

    <TypeName>Microsoft.SharePoint.WebPartPages.ContentEditorWebPart</TypeName>

    <ContentLink xmlns=”http://schemas.microsoft.com/WebPart/v2/ContentEditor&#8221; />


    <Content xmlns=”http://schemas.microsoft.com/WebPart/v2/ContentEditor”&gt;<Value>&lt;div class=&quot;block&quot;&gt;

    &lt;h3&gt;Related Pages&lt;/h3&gt;

    &lt;div class=&quot;rlinks&quot;&gt;

    &lt;ul&gt;

    &lt;li&gt;

    &lt;a href=&quot;/Pages/ABC.aspx&quot;&gt; ABC&lt;/a&gt;&lt;/li&gt;

    &lt;/ul&gt;

    &lt;/div&gt;

    &lt;/div&gt;

    &lt;div class=&quot;block&quot;&gt;

    &lt;h3&gt;By Telephone &lt;/h3&gt;

    &lt;div class=&quot;rlinks&quot;&gt;

    &lt;ul&gt;

    &lt;li&gt;Tel : +92 336 335 334 6&lt;/li&gt;

    &lt;li&gt;Fax : +92 336 335 334 6&lt;/li&gt;

    &lt;/ul&gt;

    &lt;/div&gt;

    &lt;/div&gt;

    &lt;div class=&quot;block&quot;&gt;

    &lt;h3&gt;

    &lt;a href=&quot;#&quot;&gt;By Email &lt;/a&gt;&lt;/h3&gt;

    &lt;div class=&quot;rlinks&quot;&gt;

    &lt;ul&gt;

    &lt;li&gt;

    &lt;a href=&quot;#&quot;&gt; ABC @ ABC.com&lt;/a&gt;&lt;/li&gt;

    &lt;/ul&gt;

    &lt;/div&gt;

    &lt;/div&gt;

    </Value></Content>

    <PartStorage xmlns=”http://schemas.microsoft.com/WebPart/v2/ContentEditor&#8221; />

    </WebPart>

  • Paste the tweaked web part XML

    <AllUsersWebPart
    WebPartZoneID=xc…
    WebPartOrder=1>

    <![CDATA[

    ‘Your tweaked XML’
    ]]>

    </AllUsersWebPart>

     

App / List View:    

In SharePoint 2013 you won’t find List view web part, as lists are given a new name and that is App. So how to add an app part and how to export it.

  • For that we will be using SharePoint
    Designer as there is no option to export App
    J.
  • Open SharePoint designer.
  • Navigate to your site on which you need to add a web part, moreover site should have that list too for which we are going to export the web part.
  • App an aspx page in that site from SharePoint designer.
  • Edit that added page in advance mode.
  • Add web part zone as shown below


 

  • Then into added web part zone.
    • Select Data View from the ribbon and select your list , Mine is LegalDocuments


 

  • After List been added to you zone. Click Web part from ribbon on top of the page and select ‘To File’.


  • You will be prompted to save the web part at your desired location and name.
  • Save it and open the saved file with Note Pad or Note Pad ++.
  • It will look like the following

    <?xml version=”1.0″ encoding=”utf-8″ ?>

    <webParts>

        <webPart xmlns=”http://schemas.microsoft.com/WebPart/v3″&gt;

            <metaData>

                <type name=”Microsoft.SharePoint.WebPartPages.XsltListViewWebPart, Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c” />

                <importErrorMessage>Cannot import this Web Part.</importErrorMessage>

            </metaData>

            <data>

                <properties>

                    …

                    <property name=”ListName” type=”string”>LegalDocuments<property>

                    <property name=”ListDisplayName” type=”string” null=”true” />

                    <property name=”AllowZoneChange” type=”bool”>True</property>

                    <property name=”ChromeState” type=”chromestate”>Normal</property>

                    <property name=”DisableSaveAsNewViewButton” type=”bool”>False</property>

                    <property name=”ViewFlag” type=”string” />

                    <property name=”DataSourceID” type=”string” />

                    <property name=”ExportMode”

                    <property name=”Title” type=”string” />

                    <property name=”PageType” type=”Microsoft.SharePoint.PAGETYPE, Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c”>PAGE_NORMALVIEW</property>

                    <property name=”DataSourcesString” type=”string” />

                    <property name=”AllowClose” type=”bool”>True</property>

                    <property name=”InplaceSearchEnabled” type=”bool”>True</property>

                    <property name=”WebId” type=”System.Guid, mscorlib, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089″>b369b8ef-fb3b-4a8e-ba1e-ae04fd57441c</property>

                    <property name=”Height” type=”string” />

                    <property name=”GhostedXslLink” type=”string”>main.xsl</property>

                    <property name=”DisableViewSelectorMenu” type=”bool”>False</property>

                    <property name=”DisplayName” type=”string”>LegalDocuments</property>

                    <property name=”IsClientRender” type=”bool”>False</property>

                    <property name=”XmlDefinition” type=”string”>

        &lt;View Name=”{807234E4-D763-435E-A84A-A5E20727A5FA}” MobileView=”TRUE” Type=”HTML” DisplayName=”All Documents” Url=”/LegalDocuments/Forms/AllItems.aspx” Level=”1″ BaseViewID=”1″ ContentTypeID=”0x” ImageUrl=”/_layouts/15/images/dlicon.png?rev=23″&gt;

            &lt;Query/&gt;

            &lt;ViewFields&gt;

                &lt;FieldRef Name=”DocIcon”/&gt;

                &lt;FieldRef Name=”LinkFilename”/&gt;

                &lt;FieldRef Name=”Modified”/&gt;

                &lt;FieldRef Name=”Editor”/&gt;

                &lt;FieldRef Name=”_ModerationStatus”/&gt;

            &lt;/ViewFields&gt;

            &lt;RowLimit Paged=”TRUE”&gt;30&lt;/RowLimit&gt;

            &lt;JSLink&gt;clienttemplates.js&lt;/JSLink&gt;

            &lt;XslLink Default=”TRUE”&gt;main.xsl&lt;/XslLink&gt;

            &lt;Toolbar Type=”Standard”/&gt;

        &lt;/View&gt;

    </property>…

        &lt;ParameterBinding Name=”NoAnnouncements” Location=”Resource(wss,noXinviewofY_LIST)” /&gt;

        &lt;ParameterBinding Name=”NoAnnouncementsHowTo” Location=”Resource(core,noXinviewofY_DEFAULT)” /&gt;

        &lt;ParameterBinding Name=”AddNewAnnouncement” Location=”Resource(wss,addnewitem)” /&gt;

        &lt;ParameterBinding Name=”MoreAnnouncements” Location=”Resource(wss,moreItemsParen)” /&gt;

    </property>

                    <property name=”DataSourceMode” type=”Microsoft.SharePoint.WebControls.SPDataSourceMode, Microsoft.SharePoint, Version=15.0.0.0, Culture=neutral, PublicKeyToken=71e9bce111e9429c”>List</property>

                    <property name=”AutoRefreshInterval” type=”int”>60</property>

                    <property name=”AsyncRefresh” type=”bool”>False</property>

                    <property name=”HelpUrl” type=”string” />

                    <property name=”MissingAssembly” type=”string”>Cannot import this Web Part.</property>

                    <property name=”XslLink” type=”string” null=”true” />

                    <property name=”SelectParameters” type=”string” />

                </properties>

            </data>

        </webPart>

    </webParts>

  • Important things to tweak in App / List view are highlighted.
  • Make sure List name is proper.
  • Make sure URL of view is proper.
  • Final thing to do is , This will be added under <View ….</View>
    instead of <AllUsersWebPart … so delete AllUsersWebPart

    Tag and place View tag.

     

    <View
    List=LegalDocuments
    BaseViewID=1
    WebPartZoneID=xb…………
    WebPartOrder=1 >

    <![CDATA[

    ‘Copy Tweaked XML here’
    ]]>

    </View>

    Happy CodingJ.


 

Setting Drop Down Selected Index programmatically.

June 9, 2012 4 comments

What is you need to select the item from the drop down list programmatically where you don’t know on which index it would be. For that simplest way is

ddlData.SelectedIndex=ddlData.Items.IndexOf(ddlData.Items.FindByText("value"));
Happy CodingSmile
 

Reset values of all controls in form/ASP.Net page using C#

December 20, 2011 2 comments

Today i am going to blog a post which is not a rocket science , well there is no rocket science ever posted from my side 🙂

I was lying in my blanket , enjoying cozy winter using the laptop , when friend of mine asked ‘what if we need to clear the values of all controls on form to defaults’.

That was not a tough question , more then tough it’s interesting as there are many scenarios in which we need to give default values to the controls on web or form in single click.

foreach is the key loop in that.

So lets start exploring this query.

Initially a form with following controls is designed.

frmMain

  • Check Box : name is chkBox
  • Radio Button : name is rbtn
  • Text Box : name is txtBox
  • Drop Down : name is cmbBox
  • Button : name is btnReset

Now requirement is to set the default values to all the controls on the form or web. Right now i am going with form.

Few controls are being used to make it more easy to understand.
Here comes the code for that on btnReset_Click

private void btnReset_Click(object sender, EventArgs e)

       {

           foreach (Control c in this.Controls)

           {

               switch (c.GetType().ToString())

               {

                   case "System.Windows.Forms.TextBox":

                       ((TextBox)c).Text = string.Empty;

                       break;

                   case "System.Windows.Forms.ComboBox":

                       ((ComboBox)c).SelectedIndex = 1;

                       break;

                   case "System.Windows.Forms.CheckBox":

                       ((CheckBox)c).Checked = false;

                       break;

                   case "System.Windows.Forms.RadioButton":

                       ((RadioButton)c).Checked = false;

                       break;

               }

           }

       }

I have assigned the default values in Switch statement.

frmMain

In case of web page , class representing text box “System.Windows.Forms.TextBox” would have been “System.Web.UI.WebControls.TextBox”

 

Happy coding :).

How to increase debugging time of SharePoint sites using iis7

November 1, 2011 Leave a comment

Debugging is always life saving drug for developers 🙂 But its so annoying when SharePoint developer is in state of debugging and suddenly Giant Annoying Message appears that

iis

Solution to this annoying thing is to increase the debugging time, so here is the simple procedure

  • Open IIS7 Manager.
  • Select the App Pool on which site you want to debug is hosted.
  • Go to its Advance settings from the Actions Panel ‘ Right most  side’.
  • Under the ‘Process Model’.
  • Change ‘Ping enabled to ‘false’’.
  • Maximum Response time (Seconds) : from 30 to 999999

Increase Debug Time

Press OK and enjoy 🙂

Water marking for asp:textbox using javascript

A while ago i had a task to implement water mark on asp:textbox , well a short one but its always good to have the tasks which are not done before as they provides room for improvement and learning. In my opinion its not bad to learn even a single character a day .

Simple javascript function to deal in.

<script
type=”text/javascript”
language=”javascript”>
function
clearWaterMark()
{


var text = document.getElementById(‘<%=txtExample.ClientID %>’).value;


if(text.match(“^Example”))

{

document.getElementById(‘<%=txtExample.ClientID %>’).value= ;

}

}

function addWaterMark()

{ if(document.getElementById(‘<%= txtExample.ClientID %>’).value== )

{

document.getElementById(‘<%= txtExample.ClientID %>’).value=“Example C:\\FileName.p12”;

}

}
</script>

 

<asp:TextBox
ID=”txtExample”
Width=”233px”
runat=”server”
Font-Size=”XX-Small”
ToolTip=”Type full path of certificate including extention.”
onClick=”clearWaterMark()”
onBlur=”addWaterMark()”>Example C:\Certificate.p12</asp:TextBox>

 

Javascript functions are called on events

  • onClick=”clearWaterMark()”
    //Checks if there is text in textbox starting with “Example” then clearing that.
  • onBlur=”addWaterMark()” // Checkis if there is no text in textbox then adding the text to textbox

 

Happy Coding J

How to display the password even textmode=”password” to textbox again?

June 2, 2011 4 comments

Few days back i was trying to get  stored password  into the ‘asp:textbox’  with textmode=”Password”.

I just wanted to see the stored password , like there are some scenarios where you need to show the stored password “NOT Text” but  in “* * * * ..”.

In my case, Initially password entered in txtPassowrd was stored in xml and i was required to get the password from xml and display the password in the textbox.

As there are many scenarios in which we need to show password again, hmmm as in update profile cases.

After some R&D , finally solution was in my arms :).

Solution to this was in just one line :).

textPassword.Attributes.add(“value”,”password”);

just pass the text [stored password] to “password” and it will work for you.

 password

Thanks.