[英]How to add custom code to a Text Page type item created in Umbraco
我最近在Umbraco 7上安裝了Txt入門工具包。在管理頁面的內容部分,我在主頁下創建了一個文本頁面類型的頁面。 對於頁面,我僅限於選擇圖片並編寫內容。 在我以前的ASP.net網站上,我有以下代碼從用戶那里獲取一些輸入並進行成本估算:
<div class="costSection" runat="server">
برآورد قیمت ترجمه:
<br />
<asp:Label runat="server" Text="نوع ترجمه "></asp:Label>
<asp:DropDownList ID="ddlTranslationType" runat="server">
<asp:ListItem Value="0">فارسی به انگلیسی</asp:ListItem>
<asp:ListItem Value="1">انگلیسی به فارسی</asp:ListItem>
<asp:ListItem Value="2">فرانسه به فارسی</asp:ListItem>
</asp:DropDownList>
<br />
<asp:Label runat="server" Text="تعداد کلمه "></asp:Label>
<asp:TextBox ID="txtWordsCount" runat="server" CssClass="costSection" ></asp:TextBox><br />
<asp:Button runat="server" ID="btnCalcCost" CssClass="costSection" OnClick="btnCalcCost_Click" Text="محاسبه هزینه"/>
<asp:Label Text="" ID="lblCost" runat="server" CssClass="costSection"> </asp:Label>
</div>
C#代碼是:
protected void btnCalcCost_Click(object sender, EventArgs e)
{
int userChoice;
try{int.TryParse(ddlTranslationType.SelectedValue,out userChoice);}
catch(Exception ex){
lblCost.ForeColor = System.Drawing.Color.Red;
lblCost.Text=ex.Message;
return;
}
int wordsCount;
if (txtWordsCount.Text == null || !int.TryParse(txtWordsCount.Text,out wordsCount))
{
lblCost.ForeColor = System.Drawing.Color.Red;
lblCost.Text = "لطفا تعداد کلمات را وارد کنید";
return;
}
float cost=0;
switch (userChoice)
{
case 0: //Farsi-English
cost = (float)wordsCount / 250 * 13000;
break;
case 1: //English-Farsi
cost = (float)wordsCount / 300 * 8000;
break;
case 2: //French-Farsi
cost = (float)wordsCount / 250 * 20000;
break;
}
long estimatedCost = (long)cost;
lblCost.ForeColor= System.Drawing.Color.Green;
lblCost.Text = estimatedCost.ToString()+" تومان ";
}
在我的新Umbraco帖子中,我想要這個代碼,但是我不知道在哪里添加標記和C#代碼以使其起作用。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.