一把umbraco用户控件:用户控件本身获取usercontrol.property.Id? [英] Umbraco usercontrol: Get usercontrol.property.Id within the usercontrol itself?
问题描述
我遇到一些麻烦与一把umbraco用户控件..
我试图建立一个照相馆..我有上有一个mediapicker一个用户控件,并保存我想产生拾取文件夹中所有mediafiles的缩略图。到目前为止好..
i'm having some trouble with the umbraco usercontrol.. I'm trying to develop a Photo Gallery.. I have a usercontrol with a mediapicker on it, and on save i would like to generate thumbnails of all mediafiles in the picked folder. So far so good..
这可能是1号文件中包含的图片库属性的不止一个,因此,确定用于存储缩略图我必须做这样的事情的路径:
It is possible that 1 document contains more than one of the Photo Gallery properties, so to determine the path for storing the thumbnails i have to do something like this:
PhotoGalleryStorageFolder / {DocumentID} / {} UsercontrolPropertyId
'PhotoGalleryStorageFolder/{DocumentID}/{UsercontrolPropertyId}'
检索文档编号很简单:
_currentNodeId = int.Parse(Request.QueryString["id"]);
问题是我不知道的别名,我不想硬code在我的用户控件可以有它的多个实例。
The problem is that i do not know the alias and i dont want to hardcode it in my usercontrol as there can be more instances of it..
code:
private Int32 _currentNodeId = -1;
private Int32 _currentPhotoGalleryId = -1;
private String _value = ""; // Holds MediaPickerValue;
protected void Page_Load(object sender, EventArgs e)
{
initialize();
}
#region Initialize
private void initialize()
{
_currentNodeId = int.Parse(Request.QueryString["id"]);
/////// PROBLEM \\\\\\\\\
_currentPhotoGalleryId = -1; // How to retrieve this?!?!
\\\\\\\ PROBLEM /////////
Document d = new Document(_currentNodeId);
if (!Page.IsPostBack)
{
this.setMediaPickerValue(_value);
this.setPrevMediaPickerValue(_value);
}
else
_value = this.getMediaPickerValue();
Response.Write("_currentNodeId: " + _currentNodeId.ToString() + "<br />");
Response.Write("_value: " + _value + "<br />");
}
void Document_AfterSave(Document sender, umbraco.cms.businesslogic.SaveEventArgs e)
{
}
#endregion
#region MediaPickerValue
private String getMediaPickerValue()
{
return mediaPicker.Value;
}
private void setMediaPickerValue(String value)
{
mediaPicker.Value = value;
}
private String getPrevMediaPickerValue()
{
return prevMediaPickerValue.Value;
}
private void setPrevMediaPickerValue(String value)
{
prevMediaPickerValue.Value = value;
}
#endregion
#region OnSave
private void onSave()
{
String currentValue = this.getMediaPickerValue();
String prevValue = this.getPrevMediaPickerValue();
if (currentValue != prevValue) HttpContext.Current.Response.Write("Hergenereer thumbs.<br />");
else HttpContext.Current.Response.Write("Thumbs hoeven niet opnieuw te worden gegenereerd.<br />");
this.setPrevMediaPickerValue(currentValue);
}
#endregion
public object value
{
get
{
onSave();
return this.getMediaPickerValue();
}
set
{
Response.Write("Set triggered<br />");
String val = string.IsNullOrEmpty(value.ToString()) || value == null ? "" : value.ToString();
_value = val;
}
}
任何帮助将是巨大的..日Thnx提前!
Any help on this would be great.. Thnx in advance!
推荐答案
我最终增加一个额外的文本框(仅管理员可见)到用户控件,所以开发人员现在可以定义一个子文件夹中图片集锦的每个实例。日Thnx反正所有帮助。
I ended up adding an extra textbox (only visible to admins) to the usercontrol, so the developer can now define a subfolder for each instance of the PhotoGallery. Thnx for all the help anyway.
这篇关于一把umbraco用户控件:用户控件本身获取usercontrol.property.Id?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!