我iframe在父页面中调用JavaScript函数时遇到问题.这是我的两页:
mainPage.html
<html>
<head>
<title>MainPage</title>
<script type="text/javascript">
function Reset()
{
if (document.all.resultFrame)
alert("resultFrame found");
else
alert("resultFrame NOT found");
if (typeof (document.all.resultFrame.Reset) == "function")
document.all.resultFrame.Reset();
else
alert("resultFrame.Reset NOT found");
}
</script>
</head>
<body>
MainPage<br>
<input type="button" onclick="Reset()" value="Reset"><br><br>
<iframe height="100" id="resultFrame" src="resultFrame.html"></iframe>
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
resultFrame.html
<html>
<head>
<title>ResultPage</title>
<script type="text/javascript">
function Reset()
{
alert("reset (in resultframe)");
}
</script>
</head>
<body>
ResultPage
</body>
</html>
Run Code Online (Sandbox Code Playgroud)
(我知道document.all不推荐这个,但这个页面只能在内部用IE查看,我不认为这是问题)
当我按下重置按钮时,我得到"找到resultFrame"和"找不到resultFrame.Reset".它似乎有一个框架的引用,但不能调用框架上的功能,为什么会这样?
如何在运行时以各种方式修改propertygrid?我希望能够添加和删除属性并添加"动态类型",我的意思是使用TypeConverter导致在propertygrid中生成运行时生成的下拉列表.
我实际上已经能够做这两件事(添加/删除属性和添加动态类型)但不能同时单独使用.
为了实现在运行时添加和删除属性的支持,我使用了这个代码项目文章并稍微修改了代码以支持不同的类型(不仅仅是字符串).
private System.Windows.Forms.PropertyGrid propertyGrid1;
private CustomClass myProperties = new CustomClass();
public Form1()
{
InitializeComponent();
myProperties.Add(new CustomProperty("Name", "Sven", typeof(string), false, true));
myProperties.Add(new CustomProperty("MyBool", "True", typeof(bool), false, true));
myProperties.Add(new CustomProperty("CaptionPosition", "Top", typeof(CaptionPosition), false, true));
myProperties.Add(new CustomProperty("Custom", "", typeof(StatesList), false, true)); //<-- doesn't work
}
/// <summary>
/// CustomClass (Which is binding to property grid)
/// </summary>
public class CustomClass: CollectionBase,ICustomTypeDescriptor
{
/// <summary>
/// Add CustomProperty to Collectionbase List
/// </summary>
/// <param name="Value"></param> …Run Code Online (Sandbox Code Playgroud) 使用缩放变换在不同比例下绘制时发现了PDFSharp的问题.
在此示例中,我们绘制了两个不同比例的矩形,从中生成XPS FixedDocumentSequence,最后使用PDFsharps XPS转换器将XPS转换为PDF.
var visual = new DrawingVisual();
DrawingContext dc = visual.RenderOpen();
// Setup transformations.
dc.PushTransform(new TranslateTransform(0, 1122.0));
dc.PushTransform(new ScaleTransform(3.77857136726379, -3.77857136726379));
dc.PushTransform(new TranslateTransform(-1719.41186523438, -1410.32360839844));
dc.PushTransform(new ScaleTransform(0.0117647061124444, 0.0117647061124444));
// Draw red rectangle.
var redPen = new Pen(Brushes.Red, 1);
var rectGeo1 = new RectangleGeometry(new Rect(160000, 130000, 8000, 5000));
dc.DrawGeometry(Brushes.Transparent, redPen, rectGeo1);
// Pop two transformations.
dc.Pop();
dc.Pop();
// Draw blue rectangle.
var bluePen = new Pen(Brushes.Blue, 0.5);
var rectGeo2 = new RectangleGeometry(new Rect(12, 12, 150.9408, 107.088539));
dc.DrawGeometry(Brushes.Transparent, bluePen, rectGeo2);
dc.Close(); …Run Code Online (Sandbox Code Playgroud) 现在我有一个继承的页面System.Web.UI.Page基类和继承的usercontrols的另一个基类System.Web.UI.UserControl,这些类包含相同的方法.由于C#不支持多重继承,因此我无法将这两个类合并为一个继承Page和UserControl的类.
将功能保留在两个基类中但是只在一个地方实现这些方法的最佳方法是什么?
我正在考虑创建一个接口,让两个基类调用包含接口实现的第三个类.有没有更好的方法,所以当我添加一个新方法时,我不必在三个地方做到这一点(即使实现仅在第三类).
我在我的网站上使用URL重写来获取以下URL:
http://mysite.com/users/john
而不是
http://mysite.com/index.aspx?user=john
要使用IIS6实现这种无扩展的重写并且无法访问托管服务器,我使用"404-approach".当服务器找不到请求时,执行映射的404页面,因为这是一个aspx页面,可以执行重写(我可以使用托管服务上的控制面板设置404映射).
这是Global.asax中的代码:
protected void Application_BeginRequest(object sender, EventArgs e)
{
string url = HttpContext.Current.Request.Url.AbsolutePath;
if (url.Contains("404.aspx"))
{
string[] urlInfo404 = Request.Url.Query.ToString().Split(';');
if (urlInfo404.Length > 1)
{
string requestURL = urlInfo404[1];
if (requestURL.Contains("/users/"))
{
HttpContext.Current.RewritePath("~/index.aspx?user=" + GetPageID(requestURL));
StoreRequestURL(requestURL);
}
else if (requestURL.Contains("/picture/"))
{
HttpContext.Current.RewritePath("~/showPicture.aspx?pictureID=" + GetPageID(requestURL));
StoreRequestURL(requestURL);
}
}
}
}
private void StoreRequestURL(string url)
{
url = url.Replace("http://", "");
url = url.Substring(url.IndexOf("/"));
HttpContext.Current.Items["VirtualUrl"] = url;
}
private string GetPageID(string requestURL)
{
int idx = requestURL.LastIndexOf("/"); …Run Code Online (Sandbox Code Playgroud) asp.net ×2
c# ×2
.net ×1
iframe ×1
javascript ×1
pdfsharp ×1
postback ×1
propertygrid ×1
winforms ×1