我有一个非常基本的正则表达式,我无法弄清楚为什么它不起作用所以问题是两部分.为什么我当前的版本不起作用,什么是正确的表达式.
规则很简单:
因此,以下案例应解决如下:
我正在使用的表达式是:
^%?\S{3}
Run Code Online (Sandbox Code Playgroud)
对我来说意味着:
^ - 字符串开头%? - 贪婪检查0或1%字符\S{3} - 其他3个不是空格的字符问题是,由于%?某种原因,没有进行贪婪的检查.如果它存在的话,它不会占用%字符,所以'%AB'的情况正在传递,我认为应该失败.为什么%?不吃%字符?
有人请告诉我光:)
编辑:我使用的答案是下面的Dav:^(%\S{3}|[^%\s]\S{2})
尽管这是一个2部分的答案,Alan真的让我理解为什么.我没有使用他的版本,^(?>%?)\S{3}因为它有效但不是在javascript实现中.两个伟大的答案和很多帮助.
我正在尝试在转发器中填充下拉列表,但我不是很成功.我可能使用错误的EventArgs e.
这是我的aspx代码:
<asp:Repeater runat="server" id="criteriaScore">
<HeaderTemplate>
<ul>
<li class="header"><span class="item">Kriterie</span><span class="value">Poeng</span><span class="description">Beskrivelse</span></li>
</HeaderTemplate>
<ItemTemplate>
<li>
<span class="item"> <%# Eval("criteria") %>:</span>
<asp:DropDownList id="ddlRating" runat="server" autopostback="true" enableviewstate="false"></asp:DropDownList>
<span class="value score<%# Eval("lvl") %>" title="<%# Eval("description") %>"> </span>
</li>
</ItemTemplate>
<FooterTemplate>
</ul>
</FooterTemplate>
</asp:Repeater>
Run Code Online (Sandbox Code Playgroud)
而背后的代码:
protected void criteriaScore_ItemDataBound(object sender, DataListCommandEventArgs e)
{
DropDownList ddl = (DropDownList)e.Item.FindControl("ddlRating");
for(int i=1; i > 5; i++)
{
ddl.Items.Add(new ListItem(i.ToString(), i.ToString()));
}
}
Run Code Online (Sandbox Code Playgroud)
有人可以指导我走正确的道路吗?:)
我在gridview中添加了一个按钮列.我正在使用数据通过代码填充gridview,然后将数据绑定到网格.
我现在需要查看数据的第一列,并检查列的文本是否为"NA",如果它是该列中的按钮必须被禁用.....
我怎么能做到这一点?我正在从代码中填充数据,并且按钮被预先添加到标记中的网格中
<asp:GridView ID="GridView1" runat="server" OnRowCommand="GridView1_RowCommand">
<Columns>
<asp:ButtonField Text="Delete" />
</Columns>
</asp:GridView>
GridView1.DataSource = dt;
GridView1.DataBind();
Run Code Online (Sandbox Code Playgroud) 我有如下单词列表:
List<string> words = new List<string>();
words.Add("abet");
words.Add("abbots"); //<---Return this
words.Add("abrupt");
words.Add("abduct");
words.Add("abnats"); //<--return this.
words.Add("acmatic");
Run Code Online (Sandbox Code Playgroud)
我想返回6个字母的所有单词,以字母"a"开头,并且"t"作为第5个字母,结果应该返回单词"abbots"和"abnats".
var result = from w in words
where w.StartsWith("a") && //where ????
Run Code Online (Sandbox Code Playgroud)
我需要添加什么条款来满足第5个字母的't'要求?
我希望在第一次使用该程序时为用户提供使用教程的选项.我尝试在Form.Load事件中添加它,但是在弹出Messageboxes后,表单会显示出来.
这就是为什么我想知道,加载表格后是否有任何事件被解雇?
如果没有,有没有办法在加载后立即执行操作?
我遇到会话到期问题.首先它每20分钟到期,它会抛出一个错误......
我试图修复它:
if (Session["userName"].ToString() == null)
{
Session.RemoveAll();
Response.Redirect("~/Login.aspx?sessionError=" + "*Session Expired on pageload PleaseLog in again");
}
Run Code Online (Sandbox Code Playgroud)
但是我收到以下错误:
你调用的对象是空的.
我的堆栈跟踪是:
[NullReferenceException:对象引用未设置为对象的实例.] c:\ Users\jagmit\Documents\Visual Studio 2008\Projects\copiunGUI\copiunGUI\Site1.Master.cs:224 copiunGUI中的copiunGUI.Site1.checksession() .Site1.TreeViewMain_Unload(Object sender,EventArgs e)在C:\ Users\jagmit\Documents\Visual Studio 2008\Projects\copiunGUI\copiunGUI\Site1.Master.cs:210 System.Web.UI.Control.OnUnload(EventArgs e) )+8681754 System.Web.UI.Control.UnloadRecursive(Boolean dispose)+252 System.Web.UI.Control.UnloadRecursive(Boolean dispose)+188 System.Web.UI.Control.UnloadRecursive(Boolean dispose)+188 System. Web.UI.Control.UnloadRecursive(Boolean dispose)+188 System.Web.UI.Control.UnloadRecursive(Boolean dispose)+188 System.Web.UI.Page.UnloadRecursive(Boolean dispose)+23 System.Web.UI.Page .ProcessRequestCleanup()+43
我web.config是:
<authentication mode="Forms">
<forms loginUrl="Login.aspx" defaultUrl="~/Default.aspx" name="Cookie" timeout="10080" path="/">
</forms>
</authentication>
<authorization>
<deny users="?"/>
<allow users="*"/>
</authorization>
Run Code Online (Sandbox Code Playgroud)
请帮忙.......
谢谢
谢谢你输入的人......
我试过这个:
if (Session["userName"] == null)
{
Session.RemoveAll(); …Run Code Online (Sandbox Code Playgroud) 基本上我想要一个按钮,在包含我的http://fake.com/Report/PageFixes...页面的新窗口中打开一个页面.目前我在一个表单中有一个按钮,但如果有更好的方法,那么我也是这样做的.
<% using (Html.BeginForm("PageFixes", "Report", new { id = 9 }, FormMethod.Get, new { onSubmit="window.open()" })) %>
<% { %>
<%= Html.CSButton(new ButtonViewData() { Text = "Submit" })%>
<% } %>
Run Code Online (Sandbox Code Playgroud) 有谁知道如何添加一个带有"actionlinkwithimage"的确认对话框?
我有几列,并且我想在某些像这样的左边和右边有边框:
| column1 column2 | column3 column4 |
如果我在中指定边框ItemStyle,则边框会在两侧显示,并且不会呈现第1列和第2列与第3列和第4列之间缺少列的情况。
有什么建议么?
我有一个List<string>我正在使用DataSource的GridView.我不想自动生成列(它将"Item"作为标题).我怎么放的DataField,以如果我使用的是得到字符串BoundField?又<%# Eval( [whatgoeshere] ) %>在标记中?
asp.net ×6
c# ×6
data-binding ×3
gridview ×3
.net ×2
asp.net-mvc ×2
border ×1
button ×1
coding-style ×1
events ×1
javascript ×1
linq ×1
load ×1
regex ×1
regex-greedy ×1
repeater ×1
session ×1
string ×1
winforms ×1