November Happy Hour will be moved to Thursday December 5th.

Properties issues... How create New Properties on Default2.aspx

Vote:
 

For test the operation with the Properties we use an existing default project MyEPiServerSite.
No new parameters and settings were not used, but the connection string to the database connectionStrings.config

Step 1
Check what properties exist and are available in the Default.aspx
(added a TextBox and it print all of the existing Property values)
    protected void Button2_Click(object sender, EventArgs e)
    {
        TextBox2.Text = "";
        for (int i = 1; i < CurrentPage.Property.Count; i++)
        {
            try
            {
                TextBox2.Text = TextBox2.Text + i.ToString() + " [" + CurrentPage.Property[i].Name + "]    " + CurrentPage.Property[i].Value.ToString() + Environment.NewLine;
            }
            catch (Exception ex)
            {
                TextBox2.Text = TextBox2.Text + i.ToString() + " [" + CurrentPage.Property[i].Name + "]    " + ex.Message + Environment.NewLine;

            }
        }
    }

Step 2
Added to the project a new form Default2.aspx
Registered it in Admin Mode as a new Page Type
Add a new property "prpDefault2" to form (Page Type) Default2.aspx

Step 3
On a new form Default2.aspx added a TextBox and print all of the existing Property values
(See above code)

Result:
On a new form Default2.aspx printed the same values ​​as for Default.aspx
Property "prpDefault2" not found.

 

Questions:

1. What have we done wrong?

2. Why the new property ("prpDefault2") is not available on a new form Default2.aspx

#51242
May 30, 2011 11:27
Vote:
 

What happens if you try to printe the property directly into the markup?

E.g.

<%= CurrentPage ["prpDefault2"] %>

    

Or this in the code behind:

 

PropertyData property = CurrentPage.Property["prpDefault2"];
if (property != null && !property.IsNull)
{
    DoSomething();
}

    

Be aware property names are case sensitive.

 

 

#51687
Edited, Jun 21, 2011 9:02
This thread is locked and should be used for reference only. Please use the Episerver CMS 7 and earlier versions forum to open new discussions.
* You are NOT allowed to include any hyperlinks in the post because your account hasn't associated to your company. User profile should be updated.