简体   繁体   English

从Ajax更新存储过程

[英]UPDATE stored procedure from Ajax

I'm writing an application that on page load pulls information from SQL based on an ID from the url and then I convert it to a Int. 我正在编写一个应用程序,该应用程序会在页面加载时根据URL中的ID从SQL中提取信息,然后将其转换为Int。

request_id = Request.QueryString["ID"].ToString();
RequestID = Convert.ToInt32(request_id);

I am then trying to submit changes on the page back to the database in an SQL update stored procedure. 然后,我尝试通过SQL更新存储过程将页面上的更改提交回数据库。

If I print to the page the values of the above RequestID and request_id ... I get the same number.. which is fine. 如果我将上面的RequestIDrequest_id的值打印到页面上,则会得到相同的数字..很好。

However I have two submit buttons on my page.. when I click the first one it pops up the following. 但是,我的页面上有两个提交按钮。.当我单击第一个按钮时,将弹出以下内容。

<ajaxToolkit:ConfirmButtonExtender ID="cbe" runat="server"
ConfirmText="Want to Save?" 
TargetControlID="submit_btn" 
DisplayModalPopupID="btnSave_ModalPopupExtender"        
ConfirmOnFormSubmit="true">
</ajaxToolkit:ConfirmButtonExtender>

<ajaxToolkit:ModalPopupExtender ID="btnSave_ModalPopupExtender" runat="server"
TargetControlID="submit_btn" 
PopupControlID="Panel1" 
DropShadow="true" 
CancelControlID="btnCancel"
BackgroundCssClass="modalBackground">
</ajaxToolkit:ModalPopupExtender>

<asp:Panel ID="Panel1" runat="server" CssClass="Panel_css"  >
<asp:Label ID="sqlErrorLabel" runat="server"></asp:Label>
<p style="margin-left:40px; margin-right:40px; text-align:center">Are you sure you wish to     commit this to the database?</p>
<div style="position:relative; left:23%">
<asp:Button id="btnOK" runat="server" Text="Submit" OnClick="btnOK_Click" CssClass="submit" />
<asp:Button id="btnCancel" runat="server" Text="Cancel" CssClass="submit"  />
</div>

And its between clicking the second button and running the stored procedure that the RequestID gets lost as when I print it out on the page it equals 0 when before it was 255 (for this example) 在单击第二个按钮与运行存储过程之间,RequestID丢失,因为当我在页面上打印出来时,RequestID等于255(之前为255)(对于此示例)

I know my code works because if I replace my parameter in the stored procedure with a fixed value it works fine. 我知道我的代码有效,因为如果我用固定值替换存储过程中的参数,则可以正常工作。

Any ideas? 有任何想法吗?

Cheers 干杯

you can store the request Id in hidden field. 您可以将请求ID存储在隐藏字段中。 it should work fine 它应该工作正常

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM