在我的Web应用程序中,有一个进程可以查询来自整个Web的数据,对其进行过滤并将其保存到数据库中.你可以想象这个过程需要一些时间.我目前的解决方案是增加页面超时并在加载时为用户提供AJAX进度条.这是一个问题有两个原因 - 1)它仍然需要很长时间,用户必须等待2)它有时仍然超时.
我已经涉足到线程化过程并且已经读过我应该异步将它发布到Web服务("Fire and forget").
我读过的一些参考文献:
- MSDN
- Fire and Forget
所以我的问题是 - 什么是最好的方法?
更新:在用户输入数据后,我想将它们重定向到结果页面,该页面随着进程在后台运行而逐步更新.
我读了帖子
但我的问题仍然存在.我尝试在回发时多次执行javascript,并且脚本仅在第一次加载页面时执行.
为确保脚本在每个帖子后注册,我使用guid作为javascript密钥名称.
var xyz = DateTime.Now.ToLongTimeString();
string script = @"BrokerCustomValue.value='" + CustomValueToBrokerListSerialized + "';alert('" + xyz + "');";
ScriptManager.RegisterStartupScript(this, GetType(), Guid.NewGuid().ToString(), script, true);
Run Code Online (Sandbox Code Playgroud)
我需要在更新面板中单击链接按钮后确定我的回发事件是否已激活.如果我把我的链接直接放在页面中它正在工作
1)不久前我开始学习Asp.Net,但后来我听说Ajax是"新事物".由于我不想浪费我投入Asp.Net的时间,我想知道在创建网站和网站时使用这两种技术(Asp.Net和Ajax)是否是一种常见/推荐的做法应用程序一般?
2)如果将两种技术结合使用确实是一种常见的做法,那么对于服务器端的Ajax和Asp.Net是否也是如此,或者客户端Ajax是否也可以与Asp.Net一起使用?
感谢名单
编辑:
一个)
唯一的问题是,在使用asp.net webforms时使用jquery执行ajax请求可能有点诡计(asp.net mvc的设计时考虑了jquery等框架,因此更容易实现).
你是否暗示,当与webforms一起使用时,jquery可能会有太多麻烦,因此我应该考虑使用Asp.Net Ajax?
B)我在ajax上读到的很少,它还需要调用Web服务或其他一些提供与Web服务类似功能的技术.如果为true,您使用哪种技术(WCF或Asp.Net Web服务或......)?
C)Ajax是jquery的一个子部分吗?因此,为了理解Ajax,我是否只需要购买一本关于jquery的书,还是我还需要在其标题中阅读一本带有Ajax的书?
我正在使用 anUpdatePanel来交换ActiveViewa 的MultiView。
在 IE6、7 和 8 以及 Chrome 7 中,当 UpdatePanel 返回时,我收到 JavaScript 错误。在 Firefox 3.6.1 中,没有报告错误(在错误控制台或 Firebug 中)。
错误位于 ScriptResource.axd 的第 3621 行
function Sys$_ScriptLoader$_loadScriptsInternal() {
var session = this._currentSession;
if (session.scriptsToLoad && session.scriptsToLoad.length > 0) {
var nextScript = Array.dequeue(session.scriptsToLoad);
var scriptElement = this._createScriptElement(nextScript);
if (scriptElement.text && Sys.Browser.agent === Sys.Browser.Safari) {
scriptElement.innerHTML = scriptElement.text;
delete scriptElement.text;
}
if (typeof(nextScript.src) === "string") {
this._currentTask = new Sys._ScriptLoaderTask(scriptElement, this._scriptLoadedDelegate);
this._currentTask.execute();
}
else { …Run Code Online (Sandbox Code Playgroud) 我有一个@htmlDropDownList为
@Html.DropDownList("MyList", new SelectList(Model.List, "Id", "Movie"))
Run Code Online (Sandbox Code Playgroud)
在mvc3视图中.
如何使用javascript捕获此下拉列表的选定值,并根据所选项目使用它来更改视图的内容?
当显示模式弹出窗口时,我需要以编程方式调用以下内容来设置某些内容。
Sys.Application.add_load(modalSetup);
Run Code Online (Sandbox Code Playgroud)
一些顺理成章的事情。
<script type='text/javascript'>
Sys.Application.add_load(modalSetup);
function modalSetup() {
var modalPopup = $find("PopupBehaviorId");
if (modalPopup != null) {
modalPopup.add_shown(SetFocusOnControl);
}
}
function SetFocusOnControl() {
alert('test');
}
</script>
Run Code Online (Sandbox Code Playgroud)
现在的问题是我script manager在主页上有一个。
如果我手动(不是以编程方式)将此脚本放在 的下面script manager in the master page,它将正常工作。
但是,当我使用任一方法以编程方式将其添加到模式弹出窗口(我需要)的用户控件中时ScriptManager.RegisterClientScriptBlock or Page.ClientScript.RegisterClientScriptBlock,它会引发著名的sys is undefined错误。
我知道这种情况正在发生,因为这个程序注入将其放入该行执行Head section之前。ScriptManager
我该如何解决这个问题。是否可以说将此脚本插入到页面末尾而不是顶部?
我有一些 mvc 框架可以扩展我的 .net 应用程序。他们的任务主要是向 .net 应用程序界面提供部分内容。
有趣的是,镀铬剥离了非常必要的
这是我从框架中获取和呈现数据的方法
$.ajax({
url: "/mvc/UserProfile/AddressForm?datatype=shipping",
dataType: "text", // text html script
method: "get",
cache: false,
success: function (data) {
console.log(data);
//var userProfileAdd = document.getElementById("userProfileAdd");
var userProfileAdd = $("#userProfileAdd")[0];
userProfileAdd.innerHTML = "<div>" + data + "</div>";
}
});
Run Code Online (Sandbox Code Playgroud)
Firefox、IE 等确实会检索所有数据。有谁知道为什么 chrome 会这样?
谢谢
编辑
这是console.log打印的发送到data变量的代码
<script src="/scripts/MicrosoftAjax.js" type="text/javascript"></script>
<script src="/scripts/MicrosoftMvcValidation.js" type="text/javascript"></script>
<form OnSubmit="return false;" action="/mvc/UserProfile/AddressFormPost" id="frmUserAddress" method="post"><div class="validation-summary-valid" id="validationSummary"><ul><li style="display:none"></li>
</ul></div>
<input name="__RequestVerificationToken" type="hidden" value="8Vkd039Wc3825G6CTEomJ/aXfrCyjuEY3sV/ty4znHi9yO0Th535p8VNxqvBwhJ12AREQhvTMhRVNEO6Ke3O87jDAjREg3I3dFYp2Y5geutbEOLk6KHmn6hLb4a5CFaZ3uCOm8uYgr/U4au33yaUFw==" />
<div>
Select country:
<select id="Countries" name="Countries"><option value="029">Caribbean</option>
<option …Run Code Online (Sandbox Code Playgroud) 我有以下模态弹出扩展器:
<asp:Label ID="lbl" runat="server"></asp:Label>
<asp:ModalPopupExtender ID="ModalPopupExtender1" runat="server" TargetControlID="lbl"
PopupControlID="PnlUpdate" BackgroundCssClass="modalBackground" >
</asp:ModalPopupExtender>
<asp:Panel ID="PnlUpdate" runat="server" Width="500px" CssClass="popup" Height="500px" >
<asp:UpdatePanel ID="UpnlModal" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<table width="100%">
<tr>
<td align="right">
<table width="100%" align="center">
<tr>
<td class="Heading" align="center">
<asp:Label ID="lblHeading" runat="server"></asp:Label>
</td>
</tr>
</table>
<table align="center" width="70%">
<tr>
<td align="right" class="NormalText">
<asp:DataList ID="dlMovies" runat="server" RepeatDirection="Horizontal" RepeatColumns="1"
Width="100%">
<ItemTemplate>
<table align="center" width="70%">
<tr>
<td align="left">
<asp:Label ID="lblMovieName" runat="server"></asp:Label>
</td>
</tr>
</table>
</ItemTemplate>
</asp:DataList>
</td>
</tr>
</table>
</td>
</tr>
</table>
</ContentTemplate>
</asp:UpdatePanel>
</asp:Panel>
Run Code Online (Sandbox Code Playgroud)
我想要它的scollbar. …
我在我的控制器中写了一些部分方法,它直接输入 url 访问。我想限制那些特定的方法。我使用 [ChildActionOnly] 属性来限制它。它工作正常,但我使用 Ajax 调用来访问这些方法。Ajax 调用在 ChildActionOnly 中不起作用。是否有任何属性会阻止 url 并允许 Ajax 调用?谢谢。
model-view-controller asp.net-mvc asp.net-ajax asp.net-mvc-4
我尝试通过 ajax post 请求使用验证防伪令牌,但响应是找不到根元素。我删除了防伪令牌,它工作得很好。
这是我的代码:javascript;
function Save() {
let GroupName = GetElementValue("GroupName");
let GroupId = GetElementValue("GroupId");
var Group = {
__RequestVerificationToken: gettoken(),
GroupId: :1",
GroupName: "My Group Name"
};
if (IsFormValid("GroupForm")) {
AjaxPost("/Groups/AddGroup", Group).done(function () {
GetGroups();
});
}
}
function gettoken() {
var token = '@Html.AntiForgeryToken()';
token = $(token).val();
return token;
}
function AjaxPost(url, data) {
return $.ajax({
type: "post",
contentType: "application/json;charset=utf-8",
dataType: "json",
responseType: "json",
url: url,
data: JSON.stringify(data)
});
}
Run Code Online (Sandbox Code Playgroud)
我也尝试过这个:
$.ajax({
type: "POST",
url: "/Groups/AddGroup",
data: …Run Code Online (Sandbox Code Playgroud) javascript c# model-view-controller asp.net-ajax asp.net-core
asp.net-ajax ×10
asp.net ×5
c# ×4
ajax ×3
javascript ×3
.net ×2
asp.net-3.5 ×1
asp.net-core ×1
asp.net-mvc ×1
jquery ×1
postback ×1
updatepanel ×1
webforms ×1