Sunday, December 9, 2007

Umbraco + Member Controls + Image Verification

Adding image verification to the already supplied Umbraco Member Controls is pretty straight forward. Feel free to download the source files here or the complied files here.

Example of outcome



Please remember that the members controls are part of the Umrabco repository so any upgrades could results in the following information being overwritten.


1. Copy the membercontrols.dll into the bin directory of your website.
2. Upload umbRegister.ascx and image.ascx to the usercontrols/umbracoMemberControls/ directory.
3. Create a new macro and assign image.asxc to the .net dropdown
4. Tick use in editor



4. Create a new page called Image-Verification /image-verification.aspx and then add your macro to the page.

5. Cross your fingers and hope for the best :)

Skiltz!

Thursday, December 6, 2007

Umbraco + Display Latest Page Updates

Here is a little code snippet showing how to displayed the latest n updated pages on your Umbraco site. It shows all updated pages in the same tree structure.

First of all create a new XSLT file and create a matching macro. Copy the following code into the XSLT file and save.

Okay i just spent the last 10 minutes trying to figure out how to add an XSLT to Blogger and failed miserably so just get the code here


Go to the Macro you created and create two new parameters called updateCount (number) and showDate(bool). Also in Macro properties click "use in editor" so then you can use the macro in the editor. You should be done, go to the editor and add the macro to any pages you wish.




Umbraco + Bulk Adding New Pages

Recently I have been working on a new website for a Kennel Club organisation.

Our choice of CMS was Umbraco, i had personally never used Umbraco, but a few hours into the install and everything was going pretty well.

After doing some searches on the Umbraco forums and Google i didn't seem to find any facility to bulk load pages. Its quite possible one already exists and I just haven't found it. Anyway I thought this might be a good idea so I could gain a better understanding of how the Umbraco structure works. By trade I am very junior asp.net(vb.net) programmer, have little knowledge of XML and no previous experience with C#. So there's the disclaimer continue on at your own risk.

Click here to download the files you are going to need.
  • Bukimport.aspx needs to be saved into your umbraco directory (the same one that has create.aspx in it)
  • Bulkimport.dll needs to be saved to the BIN folder.
  • Book1.xls is a example of excel file of your new pages

What the Bulk Import will do:

  • It will create new nodes for the pages you specify
  • It can publish your new documents (can be turned off)
  • You can choose which node the pages will be created into
  • You can choose the document type

What the Bulk Import won't do (yet)

  • It will not assign any macro properties to the new document (eg Hide from nav)
  • It will not add any content to the new document (its all about creating structure at the moment)
  • It will not restrict your document types (eg if you have a master document type which doesn't allow children nodes then you will still be able to add child pages)

Right given that some interest is shown then if you want these above options implemented please let me know. The content for my Dog Breed pages have not yet been constructed so I have no need to bulk import content.

The screens are very ugly and confusing at the moment but that's not that point at the moment i just need some people to test this!

Obviously at the top of the page is import which you can import a new excel file its put into the same directory as bulkImport.xls hopefully you have rights I probably should change this to usercontrols or something anyhow that's where it is for now.

Controls on the page

Parent node is obviously the parent node of the new page you are going to create, you can also select any node which is higher on the grid (because it will be inserted first and we will therefore then know the Node ID)

The dropdownlist below the Grid allows you to change the parent Nodes for all pages in the grid.

Import obviously imports the new pages. May take some time depending on how many nodes you create. I imported 200 took about 30second from memory. You will be able to tell its done when the new nodes ID's are shown

Good luck and feedback would be good.

Skiltz


Tuesday, November 27, 2007

RDLC + Page is blank + Vista

Today I ran into an issue with the report viewer control and the rendering of some RDLC reports. If I ran the application user localhost then the report would render correctly. As soon as I change from it from localhost to my computer name (http://mycomputer/report.aspx) the report control would show but the report itself would render as blank.

After hours of playing around with IIS and searching google the answer was to change the application to use the classic.asp Application pool and also set impersonation to true.

Hope this helps someone out in the future!

Monday, November 26, 2007

Update Web.config + Asp.net VB.net

Ever needed to update the web.config dynamically?

Make sure you add a reference at the top of the page to

Imports System.Web.Configuration


Dim value As String = "mskilton@gmail.com"

Dim config As Configuration =
webConfigurationManager.OpenWebConfiguration("~")
Dim appsetting As AppSettingsSection =
config.GetSection("appSettings")

appsetting.Settings("emailaddress").Value = value

config.Save()


Have fun updating your web.config programmatically!

Saturday, November 24, 2007

Blogger + ASP.net Code

Okay two posts in one day you guys are pretty lucky. After writing my first post I couldn't seem to get my asp.net code to post correctly. Using this tool http://www.manoli.net/csharpformat/
was just the ticket!

Exporting Gridview to Excel - With Checkbox

I often get the same questions asked of my while working with asp.net. If these examples seem to simplistic then please move along :)

Exporting a gridview to excel is pretty simple, there are plently of examples on the net, however not to many when it comes to only selecting certain rows to export.

an example Gridview and button


<asp:GridView ID="dg_disp" runat="server" AutoGenerateColumns="False" DataKeyNames="id" DataSourceID="SqlDataSource1" >
<Columns>
<asp:TemplateField><ItemTemplate><asp:CheckBox ID="cbSelect" runat="server" /></ItemTemplate></asp:TemplateField>
<asp:BoundField DataField="id" />
<asp:BoundField DataField="member" />
</Columns>
</asp:GridView>

<asp:button id="Button1" runat="server" />

---Code Behind---



Private Sub button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles button1.Click

' Set the content type to Excel
Response.ContentType = "application/vnd.ms-excel"

'Turn off the view state
Me.EnableViewState = False

'Remove the charset from the Content-Type header
Response.Charset = String.Empty

Dim myTextWriter As New System.IO.StringWriter()
Dim myHtmlTextWriter As New System.Web.UI.HtmlTextWriter(myTextWriter)
Dim colCount As Integer = dg_disp.Columns.Count
Dim counter As Integer = 0

'loop through all rows in the gridview
For Each row As GridViewRow In dg_disp.Rows

'skip header footers rows etc
If row.RowType = DataControlRowType.DataRow Then

'find the checkbox in the template field
Dim i As CheckBox = row.FindControl("cbSelect")

If i.Checked = True Then
While counter <> colCount

'don't output checkbox field change if checkbox is in different place
If counter <> 0 Then
Response.Write(row.Cells(counter).Text & vbTab)
End If

counter = counter + 1
End While
Response.Write(vbCr)
counter = 0
End If
End If

Next


'Write the HTML to the browser
Response.Write(myTextWriter.ToString())

'End the response
Response.End()

End Sub