워드 프레스 스타일의 짧은 코드 응용 프로그램을 처리하는 데 사용하는 것입니다. 이 값은 데이터베이스 또는 변수의 변수에서 사용자 콘텐트로 오는 콘텐트의 [short code /] 값을 대체합니다.
을 App_Code -> modul_islemler.cs
public class modul_islemler
{
public static string modul_olustur(string data){
string aranan = @"\[(.*?)\/\]";
Regex objRegex = new Regex(aranan);
MatchCollection objCol = objRegex.Matches(data);
foreach (Match item in objCol)
{data = data.Replace(item.Groups[0].Value, modul_yaz(item.Groups[1].Value.ToString()));
}
return data;
}
public static string modul_yaz(string sayfa)
{
string[] ayir = sayfa.Split(' ');
ArrayList myAL = new ArrayList();
foreach (string a in ayir)
{
myAL.Add(a);
}
if (myAL.Count < 2) myAL.Add("");
return LoadControl("~/plugins/" + myAL[0] + "/" + myAL[0] + ".ascx");
}
public static string LoadControl(string UserControlPath)
{
FormlessPage page = new FormlessPage();
page.EnableViewState = false;
// Create instance of the user control
UserControl userControl = (UserControl)page.LoadControl(UserControlPath);
page.Controls.Add(userControl);
//Write the control Html to text writer
StringWriter textWriter = new StringWriter();
//execute page on server
HttpContext.Current.Server.Execute(page, textWriter, false);
// Clean up code and return html
return textWriter.ToString();
}
public class FormlessPage : Page
{
public override void VerifyRenderingInServerForm(Control control)
{
}
}
page.aspx
<asp:Content ID="Content2" ContentPlaceHolderID="ContentPlaceHolder1" Runat="Server">
<div class="detail">
<div class="container">
<asp:Literal ID="icerikLtrl" runat="server"></asp:Literal>
</div>
</div>
</asp:Content>
page.aspx.cs
-> [slide_plugins /] 단축 코드
public partial class page : System.Web.UI.Page
{
protected void Page_Init(object sender, EventArgs e)
{
string txt="<div>blala [slide_plugins /] blabla</div>";
icerikLtrl.Text = modul_islemler.modul_olustur(txt);
}
플러그인/slide_plugins/slide_plugins.ascx
<asp:TextBox runat="server" ID="Txt1"></asp:TextBox>
<asp:Button runat="server" ID="btn1" OnClick="btn1_Click" Text="Submit"></asp:Button>
플러그인/slide_plugins/slide_plugins.ascx.cs 웹폼에서와
protected override void OnLoad(EventArgs e)
{
//kontrol yüklendiğinde çalışacak kodlar
base.OnLoad(e);
}
protected override void OnInit(EventArgs e)
{
base.OnInit(e);
InitializeComponent();
}
private void InitializeComponent()
{
btn1.Click += new EventHandler(btn1_Click);
}
protected void btn1_Click(object sender, EventArgs e)// not working....
{
Txt1.Text = "Example"; // not working....
}
ASP.Net을, ASP.Net MVC, 사용자 정의 프레임 워크? ASPX 또는 면도기 (CSHTML/VBHTML)? "이것을 쓰고 싶을 때"- VS에서 편집하는 동안 또는 페이지의 일부 처리 영역이나 DB와 같은 외부 소스의 일부 데이터를 확장하고 싶습니까? 그것은 어떻게 든 Wordpress (태그에 기반)와 관련이 있습니까? –
http://stackoverflow.com/questions/41591608/using-wordpress-style-short-codes-in-asp-net –
[내가 링크에서 한 작업이 있습니다. 당신은 그것을 검사 할 수 있습니다.] (http://stackoverflow.com/questions/41591608/using-wordpress-style-short-codes-in-asp-net) http://stackoverflow.com/questions/41591608/using-wordpress -style-short-codes-in-asp-net –