Thursday, July 31, 2008

SharePoint Mobile Enabled Lists Document Libraries

I was under the impression that by default all lists and libraries within SharePoint were mobile enabled by default. However this is not the case.

To mobile enable a list, Modify the view you would like to make mobile, scross down to the Mobile section and check the box.

Tuesday, July 29, 2008

Convert InfoPath form to PDF Document

I wanted to know how to do this for a long time now but never really spent the time to figure it out. And sometimes that's a good thing because people do it for you. As in this sample about how to convert the InfoPath form to a PDF.

http://aspalliance.com/1466_Printing_InfoPath_2007_WebBased_Forms_to_PDF.6

The solution uses an open source project for the PDF generation called iTextSharp. I haven't tried it yet but I also don't know of a lot of free pdf libraries.

Monday, July 28, 2008

Programmatically remove InfoPath digital signature

This code will need to be placed within the backed InfoPath code, although just like before I'm going to try doing this with a web part. Speaking of which, I was able to remove the Excel digital signatures using a web part however it prompted for each signature that was to be removed and there is no way to get rid of that prompt so that sucked.

Anyway, here is how to do it in InfoPath. Basically get the signature node, go to the signature child of that node and delete it.

XPathNavigator xnDoc = this.MainDataSource.CreateNavigator();

if(this.Signed) //then unsign it
{
XPathNavigator xSignedSection = xnDoc.SelectSingleNode("my:myFields/my:signatures1/my:signatures2", this.NamespaceManager);

if (xSignedSection.HasChildren)
{
xSignedSection.MoveToChild(XPathNodeType.Element); xSignedSection.DeleteSelf();
}

}

Microsoft .NET RegEx Syntax Regular Expressions

I found a very nice cheat sheet for regular expression syntax. I have to admit I sucked at this in college and still hate it. Pages like these were built for people like me.

http://regexlib.com/CheatSheet.aspx

Programmatically Post to ASP page and read results

I want to be able to POST some values to an external web site's ASP page and then programmatically read the results. The external page has no query string paramaters so I can't just create the url and read the page instead I need to create some web requests and deal with that object. This is how I did it, basically a mash up of what I found on the web but I believe more concise and clear.

//set our data
ASCIIEncoding encoding = new ASCIIEncoding();
string postData = "firstname=" + fname.Text;
postData += ("&lastname=" + lname.Text);

//compose the submission
HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https://somepage.asp");
request.Method = "POST";
request.ContentType = "application/x-www-form-urlencoded";
request.ContentLength = postData.Length;

// Post to the form.
StreamWriter swRequestWriter = new StreamWriter(request.GetRequestStream());
swRequestWriter.Write(postData);
swRequestWriter.Close();

//get the response
HttpWebResponse hwrWebResponse = (HttpWebResponse)request.GetResponse();

// Read the response
StreamReader srResponseReader = new
StreamReader(hwrWebResponse.GetResponseStream());
string strResponseData = srResponseReader.ReadToEnd();
srResponseReader.Close();

// Display the response on my page
Response.Write(strResponseData);

Now what I plan to do is screen scrape the result page and get the data I need. Ah regular expressions, I hate those. Stay tuned for that post in the next couple of days...

Thursday, July 24, 2008

Creating a SharePoint stsadm command prompt on the dektop

Create a quick shortcut to the stsadm command prompt for your SharePoint server.


http://blogs.msdn.com/scicoria/archive/2008/07/24/creating-a-wss-moss-command-prompt-on-the-desktop.aspx

Finding the SQL behind a Crystal Report

I need to find the SQL that generated a Crystal Report. All I had was the report definition file and Visual Studio 2008.

After creating a new DSN (Windows XP users click here for instructions) I opened up the report in VS and clicked the Crystal Reports menu at the top. Then Database -> Show SQL Query. A wizard will popup, click the Back button, choose the newly created DSN for your database and then click Next. Login with your credentials and click Finish. Whalla (spelling??) I now see the previously hidden SQL.