我现在可能完全偏离轨道,所以我会在这里问这个,所以有人可以帮助我.
我想要做的是将存储在applicationSettings区域的web.config中的值插入到我的aspx标记中.具体来说,我想从配置中恢复URL.这是我使用的configSection设置
<configSections>
<sectionGroup name="applicationSettings" type="System.Configuration.ApplicationSettingsGroup, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=123456">
<section name="MyApp.Properties.Settings" type="System.Configuration.ClientSettingsSection, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=12345" requirePermission="false" />
</configSections>
Run Code Online (Sandbox Code Playgroud)
稍后在该文件中的实际设置如下:
<applicationSettings>
<MyApp.Properties.Settings>
<setting name="ImagesUrl" serializeAs="String">
<value>http://resources/images/</value>
</setting>
Run Code Online (Sandbox Code Playgroud)
现在我想在标记中引用上面的值,如下所示:
<asp:Image ID="Image1" runat="server" ImageUrl="<%$AppSettings:ImagesUrl%>/Image1.jpg
Run Code Online (Sandbox Code Playgroud)
我知道有一个表达式<%$ AppSettings:ImagesUrl%>,但我没有使用web.config的appsettings部分,而是使用configSection.
编辑:我相信我只能用ExpressionBuilder来做,因为我必须将字符串与单个图像名称连接起来.我改变了上面的例子来反映这一点.
我喜欢下面的Bert Smith Code Solution来访问配置部分,只需要将它放在表达式构建器中.我坚持要从我调用配置管理器的地方覆盖GetCodeExpression方法,但我不明白如何构建表达式参数.
public class SettingsExpressionBuilder: ExpressionBuilder
{
public override CodeExpression GetCodeExpression(BoundPropertyEntry entry, object parsedData, ExpressionBuilderContext context)
{
return ??
}
Run Code Online (Sandbox Code Playgroud)
编辑
结果如下所示,适用于各种文件,而不仅仅是图像:
<asp:ScriptReference Path='<%$Code:GetAppSetting("ResourcesUrl","JS/jquery/jquery.jqplot.js")%>'
Run Code Online (Sandbox Code Playgroud)
我只是使用Microsoft的示例从表达式构建器返回任何类型的代码:
返回新的CodeSnippetExpression(entry.Expression);
GetAppSetting是我的自定义Page类中的一种方法.
我正在使用Visual Studio 2013来创建原始HTML页面(即index.html).
在我的HTML中,我正在实现自定义HTML标记.因此,Visual Studio使用波浪线强调我的自定义标记(由于"未知元素..."的警告).
为了摆脱波浪形,我将自定义标签添加到"标签特定选项"列表中Tools > Options > Text Editor > HTML (Web Forms) > Formatting > Tag Specific Options.然而,波浪线仍然存在.
有没有办法通知VS2013我的自定义HTML标签是有效的(即保持VS2013不要用波浪线强调我的自定义标签)?
好.这可能是一个非常愚蠢的问题,但无论如何我都会问它......
如何在ASP.Net标记中使用扩展和实用程序方法?例如,(比如说)我有一个名为"ToExampleString()"的DateTime扩展方法(包含在我的Common.Extensions项目中的DateTimeExtensions类中),我想在ListView的ItemTemplate中使用它在我的标记中:
<ItemTemplate>
<span><%# ((DateTime)Eval("DateStarted")).ToExampleString() %></span>
</ItemTemplate>
Run Code Online (Sandbox Code Playgroud)
我收到以下错误:
'System.DateTime'不包含'ToExampleString'的定义,并且没有扩展方法'ToExampleString'可以找到接受类型'System.DateTime'的第一个参数(你是否缺少using指令或汇编引用?)
该页面根本看不到扩展方法.
同样,如何让我的页面标记意识到实用程序类:
<span><%# ExampleUtility.ProcessDate(Eval("DateStarted") %></span>
Run Code Online (Sandbox Code Playgroud)
我需要采取哪些步骤来使这些东西工作?我想我忽略了一些明显的东西?
谢谢
有什么方法可以\parskip在某些环境中改变为不同的值,即enumerate和itemize.
我想在paragraph(\setlength{\parskip}{1em plus 1pt minus 1pt})之间有空格,但不在itemize或enumerate中.
我想利用html5的改进语义.我正在创建一个搜索区域,搜索区域应该有一个背景并包含与搜索相关的内容,例如自动填充和搜索提示.
关于什么类型的元素应该包含在搜索区域中,是否存在一些共识?
标记是这样的:
<?whatElement?>
<input type="search" placeholder="Search for a name or ID..." required />
<a href="#" class="search button">Search</a>
</?whatElement?>
Run Code Online (Sandbox Code Playgroud)
谢谢你的想法.
以下标记使用figure元素显示图像,与段落文本内联 - 因此图形在第一个内部被"包含" <p>.
<div class="object-content">
<p>
<figure class="object-inline-figure">
<img
class="object-inline-figure-image"
height="200"
src="/site_media/media/files/images/WH-487_opt.jpeg"
width="300">
<figcaption class="object-inline-figcaption">
<p class="object-inline-figcaption-caption">Lorem ipsum dolor sit amet, consectetur adipiscing elit.</p>
<p class="credits">
<span>Credit: </span>
<span class="object-inline-figcaption-caption-user-credit">
<a href="/profiles/Grey-Smith-Leigh/">Leigh Grey-Smith</a></span>,
<span class="object-inline-figcaption-caption-custom-credit">Lady Grey</span>
</p>
</figcaption>
</figure>
The relationships between functional drivers and symbolic power,
landscape and architecture, site and context, quality of materials
and quality of experience are all well considered. This high quality
design resolution can, in part, be attributed to the relationship
between designer …Run Code Online (Sandbox Code Playgroud) 如何MarkupExtension从代码中设置自定义?
您可以轻松地从Xaml设置.这同样适用于Binding和DynamicResource.
<TextBox FontSize="{Binding MyFontSize}"
Style="{DynamicResource MyStyle}"
Text="{markup:CustomMarkup}"/>
Run Code Online (Sandbox Code Playgroud)
通过代码设置相同的值需要一些不同的方法
绑定:使用textBox.SetBinding或BindingOperations.SetBinding
Binding binding = new Binding("MyFontSize");
BindingOperations.SetBinding(textBox, TextBox.FontSizeProperty, binding);
Run Code Online (Sandbox Code Playgroud)DynamicResource:使用SetResourceReference
textBox.SetResourceReference(TextBox.StyleProperty, "MyStyle");
Run Code Online (Sandbox Code Playgroud)CustomMarkup:如何MarkupExtension从代码中设置自定义?如果我打电话给ProvideValue那个案子,我怎么得到一个IServiceProvider?*
CustomMarkupExtension customExtension = new CustomMarkupExtension();
textBox.Text = customExtension.ProvideValue(??);
Run Code Online (Sandbox Code Playgroud)我在这个问题上发现了很少,所以可以做到吗?
HB回答了这个问题.只是在这里添加一些细节,为什么我想这样做.我试图为以下问题创建一个解决方法.
问题是,由于密封,您无法从中获取Binding和覆盖ProvideValue.您将不得不这样做:自定义WPF绑定标记扩展的基类.但问题是,当你返回a Binding时Setter你得到一个异常,但在Style它之外它工作正常.
我已经在几个地方读过你应该返回它MarkupExtension自己,如果它TargetObject是一个Setter允许它一旦它被应用到一个实际的reeavaluate这是FrameworkElement有道理的.
但是,只有在TargetProperty类型有效时才有效object,否则异常返回.如果您查看源代码,BindingBase …
我已经习惯了StackOverflow在编写技术帖子时提供的功能.我最喜欢的功能是
4 spaces which you can use to indent a <pre> style code block
Run Code Online (Sandbox Code Playgroud)
而且backticks you can use to format code inline,还有自动颜色语法突出显示.
我相信代码突出显示是通过谷歌的'代码美化'完成的,但我不确定其他格式.这真是太容易了!
如何在我的博客上使用此格式?
Chris Coyier不久前写过,最好的标记rel='up'在一个<nav>部分中使用,但那是在2010年,他说这种方式当时还有争议.使用HTML5标记层次结构导航栏的最佳方法是什么?这是克里斯的推荐:
<nav>
<p>
<a href="/" rel="index up up up">Main</a> >
<a href="/products/" rel="up up">Products</a> >
<a href="/products/dishwashers/" rel="up">Dishwashers</a> >
<a>Second hand</a>
</p>
</nav>
Run Code Online (Sandbox Code Playgroud) 我想将100多个RTF文件转换为Wiki Markup,但我只能在网上找到"Wiki to RTF"转换器,甚至可以在StackOverflow上找到它.
我只需要RTF - > Wiki Markup
那里有这样的东西吗?
markup ×10
html5 ×3
asp.net ×2
breadcrumbs ×1
c# ×1
custom-tag ×1
figure ×1
formatting ×1
latex ×1
markdown ×1
prettify ×1
rtf ×1
semantics ×1
validation ×1
web-config ×1
wiki ×1
wpf ×1
xaml ×1