function BindJson() {
$.ajax({
type: "POST",
url: "NewPage.aspx/SerializeJson",
data: "{}",
contentType: "application/json",
dataType: "json",
success: function (data1) {
alert(data1);
}
})
}
[WebMethod]
public static string SerializeJson()
{
JavaScriptSerializer js = new JavaScriptSerializer();
//Person p2 = js.Deserialize<Person>(str);
return "";
}
Run Code Online (Sandbox Code Playgroud)
如何将参数作为数据传递给我的serializeJson函数?
我有一个带有换行符的 asp.net 文本框,并且 sql server 2008 中不维护换行符。我该如何执行此操作?
我正在使用gridview.当我单击编辑按钮时,会出现更新和取消按钮.在修改来自EditItemTemplate的文本框中的值时,新值不会显示在事件处理程序rowupdating()中,而是获取在呈现页面时显示的值.如何从这些文本框中获取新值并继续进行?这是代码.
<asp:GridView ID="GridView1" runat="server" AutoGenerateEditButton="true" AutoGenerateColumns="false"
AutoGenerateDeleteButton="true" onrowediting="GridView1_RowEditing"
onrowupdating="GridView1_RowUpdating">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<asp:Label ID="lblId" runat="server" Text='<%# Eval("id") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txtId" runat="server" Text='<%# Eval("id") %>'></asp:TextBox>
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<ItemTemplate>
<asp:Label ID="lblName" runat="server" Text='<%# Eval("cpuname") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txtName" runat="server" Text='<%# Eval("cpuname") %>'></asp:TextBox>
</EditItemTemplate>
</asp:TemplateField>
<asp:TemplateField>
<ItemTemplate>
<asp:Label ID="lblStatus" runat="server" Text='<%# Eval("status") %>'></asp:Label>
</ItemTemplate>
<EditItemTemplate>
<asp:TextBox ID="txtStatus" runat="server" Text='<%# Eval("status") %>'></asp:TextBox>
</EditItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
protected void GridView1_RowEditing(object sender, GridViewEditEventArgs e)
{
GridView1.EditIndex = e.NewEditIndex;
}
protected void GridView1_RowUpdating(object …Run Code Online (Sandbox Code Playgroud) 泛型集合和List如何存储不同类型的对象?可能吗?
因为集合和列表是arraylist的替代品
<sessionState mode="SQLServer"
cookieless="true"
regenerateExpiredSessionId="true"
timeout="30"
sqlConnectionString="Data Source=MICHAEL;Integrated Security=SSPI;"
stateNetworkTimeout="30"/>
Run Code Online (Sandbox Code Playgroud)
我不知道我做错了什么.
我得到的错误信息是:
传递到字典中的模型项的类型为'System.Data.Linq.DataQuery`1 [MvcApplication1.ContentPageNav]',但此字典需要类型为"MvcApplication1.ContentPageNav"的模型项.
public ActionResult Edit()
{
DataClasses1DataContext dc = new DataClasses1DataContext();
var model = from m in dc.ContentPageNavs
select m;
return View(model);
}
Run Code Online (Sandbox Code Playgroud)
关于我为何会收到此错误的任何想法?任何帮助将不胜感激.
function OpenWindow(anchor) {
var toUsername = anchor.innerText;
window.open("ChatWindow.aspx?username=" + toUsername,'_blank', "width=340,height=200");
}
Run Code Online (Sandbox Code Playgroud)
这个函数在firefox中打开一个参数为undefined的页面,在google chrome中我获得了适当的值.
Firefox网址: http:// localhost:9452/ChatWindow.aspx?username = undefined
这个问题的解决方案是什么?
<asp:FormView ID="FormView1" runat="server" AllowPaging="True"
DataSourceID="SqlDataSource1" OnModeChanging="FormView1_ModeChanging">
<EditItemTemplate>
ID :
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
<br />
CpuName :
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<br />
Status :
<asp:TextBox ID="TextBox2" runat="server"></asp:TextBox>
</EditItemTemplate>
<EmptyDataTemplate>
There is no data.
</EmptyDataTemplate>
<ItemTemplate>
<table>
<tr>
<td align="right"><b>ID: </b></td>
<td><%# Eval("Id") %></td>
</tr>
<tr>
<td align="right"><b>CPUName:</b></td>
<td><%# Eval("cpuname") %></td>
</tr>
<tr>
<td align="right"><b>Status</b></td>
<td><%# Eval("status") %></td>
</tr>
</table>
<asp:LinkButton CommandName="Edit" runat="server">Edit</asp:LinkButton>
<asp:LinkButton CommandName="Insert" runat="server">Insert</asp:LinkButton>
</ItemTemplate>
<InsertItemTemplate>
<table>
<tr>
<td align="right"><b>ID: </b></td>
<td>
<asp:TextBox ID="txtFVID" runat="server"></asp:TextBox></td>
</tr>
<tr>
<td align="right"><b>CPUName:</b></td> …Run Code Online (Sandbox Code Playgroud) <table>
<tr>
<th>
Author
</th>
<th>
Title
</th>
<th></th>
</tr>
@foreach (var item in Model) {
<tr>
<td>
@Html.DisplayFor(modelItem => item.Author)
</td>
<td>
@Html.DisplayFor(modelItem => item.Title)
</td>
<td>
@Html.ActionLink("Edit", "Edit", new { id=item.ID }) |
@Html.ActionLink("Details", "Details", new { id=item.ID }) |
@Html.ActionLink("Delete", "Delete", new { id=item.ID })
@Ajax.ActionLink("View Reviews", "View", new { id = item.ID }, new AjaxOptions { UpdateTargetId = "result", InsertionMode = InsertionMode.InsertAfter })
</td>
</tr>
}
</table>
<div id="result">
</div>
public PartialViewResult View(int id)
{
ReviewModel …Run Code Online (Sandbox Code Playgroud) asp.net ×4
c# ×3
.net ×2
asp.net-mvc ×2
django ×1
firefox ×1
formview ×1
gridview ×1
javascript ×1
jquery ×1
json ×1
linq ×1
sql-server ×1