ucReport = (CLBUCUserSurveyReport)Page.LoadControl("~/Reporting/Controls/CLBUCUserSurveyReport.ascx");
phReport.Controls.Add(ucReport);
2. Set CSS in runtime
if (Message != null)
{
Message.CssClass = css;
Message.Text = msg;
}
3. _pTreeView.Attributes.Add("onclick", "OnTreeClick(event)");
4. Show or hide something in page
<%
if (CLBOA.Web.Admin.CLBWAUtils.HasAccess((int)CLBOA.Web.Admin.CLBWAAccessibleType.BANKS))
{
%>
5. link href="<%= CLBOA.Web.Admin.CLBWAUtils.GetAppPath(this.Page) + "/js/jquery-tooltip/jquery.tooltip.css"%>" rel="stylesheet" type="text/css" />
public static string GetAppPath(System.Web.UI.Page curPage)
{
string apppath = curPage.Request.ApplicationPath;
return apppath == "/" ? "" : apppath;
}
6. HttpContext.Current.Request.Url.Host
7. IList
8.
public static void OpenNewPageWindow(System.Web.UI.Page curPage, string strPage, int width, int height)
{
//Open a new window and load this page can now access the stored DataSet.
string sScript = " ";
ScriptManager.RegisterStartupScript(curPage, curPage.GetType(), "new_window_script", sScript, false);
}
public static void OpenNewPageWindow(System.Web.UI.Page curPage, string strPage)
{
OpenNewPageWindow(curPage, strPage, 600, 800);
}
9.
CLBOA.Utils.initButtonHovers = function() {
//hover states on the static widgets
$(".fg-button, .fg-button-w-icon").hover(
function() { $(this).addClass('ui-state-hover'); },
function() { $(this).removeClass('ui-state-hover'); }
);
}
protected override void OnLoad(EventArgs e)
{
ScriptManager.RegisterStartupScript(this, this.GetType(), "initButtonHovers", "CLBOA.Utils.initButtonHovers();", true);
base.OnLoad(e);
}
10.
a. A user control has a iFrame, in its iFrame, it loads MediaContainer to play video.
mediaFrame.Attributes["src"] = "/MediaContainer.aspx?mediasource=" + mediaLink + "&mediaframeid=" + mediaFrame.ClientID;
b. This is MediaContainer page
asp:ScriptManager ID="ScriptManager1" runat="server">
/asp:ScriptManager>
script type="text/javascript">
function setParentWindowSize(frameid, width, height) {
parentFrame = window.top.document.getElementById(frameid);
if (parentFrame) {
parentFrame.height = height;
parentFrame.width = width;
}
}
/script>
asp:MediaPlayer ID="MediaPlayer1" runat="server" AutoPlay="true" Windowless="true"
/asp:MediaPlayer>
c. This is MediaContainer code behind:
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
int defaultMediaWidth = 500;
string mediaSource = Request.QueryString["mediasource"];
int mediaHeight = string.IsNullOrEmpty(Request.QueryString["mediaheight"]) ? 0 : int.Parse(Request.QueryString["mediaheight"]);
int mediaWidth = string.IsNullOrEmpty(Request.QueryString["mediawidth"]) ? 0 : int.Parse(Request.QueryString["mediawidth"]);
string mediaFrameId = Request.QueryString["mediaframeid"];
if (mediaSource != null)
{
log.Debug("mediaSource=" + mediaSource);
MediaPlayer1.MediaSource = mediaSource;
MediaPlayer1.Width = mediaWidth > 0 ? mediaWidth : defaultMediaWidth;
MediaPlayer1.Height = mediaHeight > 0 ? mediaHeight : (int)(0.75 * defaultMediaWidth);
ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "setParentWindowSize", "setParentWindowSize('" + mediaFrameId + "','" + MediaPlayer1.Width + "','" + MediaPlayer1.Height + "');", true);
}
}
}
11.
protected void clbwtConfirm_Confirmed(object sender)
{
clbwtAbortReason.ShowQuestion();
}
In AbortReason page
PLLCustom:CLBInlineScript ID="test" runat="server">
script type="text/javascript">
CLBOA.Utils.ProcessDialog<%=this.ClientID%> = function() {
var dlg = $("#dialog_container<%=this.ClientID%>").dialog({ modal: true });
dlg.parent().appendTo(jQuery("form:first"));
}
/script>
div id="dialog_container<%=this.ClientID%>" title="<%= QuestionMessageHeader %>"
style="display: none">
...
/div>
In AbortReason code behind:
public void ShowQuestion()
{
ScriptManager.RegisterStartupScript(this.Page, this.GetType(), "CLBOA.Utils.ProcessDialog", "CLBOA.Utils.ProcessDialog" + this.ClientID + "();", true);
}
12. Use Control.RenderControl(HtmlTextWriter) Method to create page content based on user contorl template:
//Loading usercontrol template...
uscSlider = (ASP.slider)Page.LoadControl(@"~/controls/templates/slider.ascx");
//Filling usercontrol property...
uscSlider.Slider = (SliderVO)HttpContext.Current.Items["PCF.Slider"];
lXhtml = new StringBuilder();
aTextWriter = new StringWriter();
aHtmlTextWriter = new HtmlTextWriter(aTextWriter);
uscRotator.RenderControl(aHtmlTextWriter);
lXhtml.Append(aTextWriter.ToString());
ltrContentHomepage.Text = lXhtml.ToString();
In page:
asp:Literal ID="ltrContentHomepage" runat="server" EnableViewState="false">
没有评论:
发表评论