Adding Location Field To Registration InstantForum 4.1.4


InstantForum Question
Hi Guys,

I need to make a couple of small changes to the code but I'm having no luck as whatever I change in the code behind nothing happens on the front end. Specifically I need to add a location label below the username, so I added in the ViewTopic.ascx file this:

<InstantASP:Label id="lblLocation" Visible="true" runat="server" />


And in the code behind ViewTopic.vb I added this:

Dim lblLocation As InstantASP.Common.UI.WebControls.Label = _
DirectCast(e.Item.FindControl("lblLocation"), InstantASP.Common.UI.WebControls.Label)
lblLocation.Text = "Test"

Also whatever change I do in the code behind nothing happens, if I comment out some other sections, for example the posted date, the avatar etc. the front end still stays the same. It's like it uses another pre-compiled DLL but I can't figure it out.

Thanks for your help.

Fabio

InstantForum Question

Hi Fabio, As you know I responded to this via our ticketing system yesterday. Thank you for taking the time to confirm my response helped.

To help others I've included my original response below to your ticket...

------------------------

Hi Fabio,

Thank you for your post and detailed information. I'm sorry to hear of the trouble.

I think the problem could be your using the text property on our label control. You should use "TextNonLocalized" for example...

Dim lblLocation As InstantASP.Common.UI.WebControls.Label = _
DirectCast(e.Item.FindControl("lblLocation"), InstantASP.Common.UI.WebControls.Label)
lblLocation.TextNonLocalized = "Test"


Our label control works a little different than the standard ASP.NET label control. The Text property should be a key from the resources.xml language file. For example say you had an entry in your Globalization/en-US/Resources.xml as shown below...

<item name="MyCustomText">This is some text</item>

You could then have our label control grab the text for the key as shown below...

Dim lblLocation As InstantASP.Common.UI.WebControls.Label = _
DirectCast(e.Item.FindControl("lblLocation"), InstantASP.Common.UI.WebControls.Label)
lblLocation.Culture = "en-US"
lblLocation.Text = "MyCustomText"


This will tell our label to display "This is some text" from thje resources.xml file.

All our control work like this. If you wish to set the text use the "TextNonLocalized" unless you wish to use the rsources.xml file.

For example the following would also work...

Within resources.xml....

<item name="MyCustomLocationString">Location: [0]</item>

Dim lblLocation As InstantASP.Common.UI.WebControls.Label = _
DirectCast(e.Item.FindControl("lblLocation"), InstantASP.Common.UI.WebControls.Label)
lblLocation.Culture = "en-US"
lblLocation.Text = "MyCustomLocationString"
lblLocation.ReplaceText = User.Location


However this is only if you wish to have the text change as you swap language packs. If multiple languages are not an issue for you the easiest solution would be to simply set the TextNonLocalized property within the itemdatabound evennt.

I hope these suggestions help Fabio. Don't hesitate to respond here if we can assist further.

I look forward to your response and assisting further with any questions,

http://www.instantasp.co.uk/images/line.gif
Kindest Regards,

Ryan Healey



ryan@instantasp.co.uk
www.instantasp.co.uk
Blog | Community | Docs

http://www.instantasp.co.uk/core/assets/images/email/facebook.png http://www.instantasp.co.uk/core/assets/images/email/twitter.png http://www.instantasp.co.uk/core/assets/images/email/google.png http://www.instantasp.co.uk/core/assets/images/email/linkedin.png
GO

Login
Existing Account
Email Address:


Password:


Social Logins

Select a Forum....







InstantASP Forums


Search