umbraco 用户控件中 使用内置函数获取值

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using umbraco.BusinessLogic;
using umbraco.cms.businesslogic.web;
using umbraco.cms.businesslogic.media;
using umbraco.presentation;
using umbraco.presentation.nodeFactory;
using System.Xml;
using System.Xml.Serialization;
using umbraco.cms.businesslogic;
using System.Collections;

 

   public partial class xinwen : System.Web.UI.UserControl
    {
        protected void Page_Load(object sender, EventArgs e)
        {
            Document dcm = new Document(Convert.ToInt32(UmbracoContext.Current.PageId));
            // umbraco.library.NiceUrl(yourId);

            Guid g = new Guid("a74ea9e1-8e18-4d2a-8cf6-73c6206c5da6");新建的datatype的guid值  根据这个获取控件内容
            umbraco.cms.businesslogic.datatype.DataTypeDefinition dn = umbraco.cms.businesslogic.datatype.DataTypeDefinition.GetByDataTypeId(g);
            this.Label1.Text = this.Label1.Text + "</br>dn的值是:" + dn.Id;
            this.Label1.Text = this.Label1.Text + "</br>dn的textg值是:" + dn.Text;

            string count = umbraco.cms.businesslogic.datatype.PreValues.CountOfPreValues(dn.Id).ToString();
            this.Label1.Text = this.Label1.Text + "</br>PreValues的count值是:" + count;
            //根据id获取值

            //为下拉框赋值  然后点击获取值 "";

            drpListXs.Items.Insert(0, new ListItem("您要欣赏?", "您要欣赏?"));


            SortedList list = umbraco.cms.businesslogic.datatype.PreValues.GetPreValues(dn.Id);
            for (int i = 0; i < int.Parse(count); i++)
            {
                int Xs = i + 1;
                umbraco.cms.businesslogic.datatype.PreValue pv = (list[i]) as umbraco.cms.businesslogic.datatype.PreValue;
                this.Label1.Text = this.Label1.Text + "</br> pv.Value值是:" + pv.Value;
                drpListXs.Items.Insert(Xs, new ListItem(pv.Value, pv.Value));
            }

 

            //获取目录下的所有目录
            string value = "";
            Document[] dc = Document.GetRootDocuments();//获取所有的节点
            foreach (Document dd in dc)
            {
                if (dd.Text == "新闻")//content下面的节点名称
                {
                    if (dd.HasChildren)
                    {

                        //获取第一篇的标题描述
                        for (int i = 0; i < 1; i++)
                        {
                            value += "标题:" + dd.Children[i].getProperty("xwbiaoti").Value;//标题     DocumentType的属性xwbiaoti
                            value += "</br>描述" + dd.Children[i].getProperty("xwjianjie").Value;//描述
                        }
                        //后面两条只显示标题
                        int Sx = 0;
                        if (dd.ChildCount > 3)
                        {
                            Sx = 3;
                        }
                        else
                        {
                            Sx = dd.ChildCount;
                        }
                        for (int i = 1; i < Sx; i++)
                        {
                            value += "</br></br>标题" + dd.Children[i].getProperty("xwbiaoti").Value;//标题

                        }


                    }

                }


            }
            content.InnerHtml = value.ToString();

 

 

        }
    }

 

 

Media image;
image = new Media(Convert.ToInt32(currentDocument.getProperty("AdvertTwoImage").Value));
return image.getProperty("umbracoFile").Value.ToString();
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值