ASP.net C#JavaScript确认-为什么这么难? [英] ASP.net C# javascript confirm - why is it so hard?

查看:85
本文介绍了ASP.net C#JavaScript确认-为什么这么难?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我显然正在尝试做不可能的事情.我的用户将从下拉菜单中选择一个选项,然后单击一个按钮以应用选择.如果当前值与用户选择的值相同,则不会进行任何更改,并且我警告"该事实.但是,如果用户选择的值小于当前值,则我想与用户确认如果他继续操作或允许他停止正在执行的操作将进行哪些更改.对于所有六个可能的用户选择,情况都是相同的.我的愿望是能够在ASP.net代码中调用包含对javascript的调用的函数/子例程.然后,我必须获得用户的响应,然后将其传递回原来的位置,以确定下一步该做什么.我发现了数百篇博客文章,它们讲述了如何在按钮Evernt中执行此操作,但没有一个告诉我如何执行程序代码(函数/子例程)方法.

I am trying to do the impossible apparently. My user will select an option from a drodown and then click a button in order to apply the selection. if the current value is the same as the user selected value, no change is made and i "Alert" tothis fact. However, if the user selection is "less" than the current value i want to confirm with the user what changes will be made if he continues or allow him to stop what he is doing. The scenario is the same for all six of the possible user selections. My desire is to be able to call a function/subroutine in the ASP.net code that has the call to the javascript confirm in it. I then must get the user''s response to pass back to where it came from to determine what to do next. I have found hundreds of blog posts that tell how to do it in a button evernt, but none tell me how to do a program code (function/subroutine) method.

推荐答案

我不会说您正在尝试做不可能的事情,更像是您需要重新考虑这一过程.

只是为了返回JavaScript确认而调用服务器代码的原因是什么?无法在客户端上执行此操作吗?如果需要比较值,请使用ajax方法.

没有看到您提到的资源,我猜他们正在使用回发功能进行演示,因为它们涉及按钮事件.您几乎可以随时从JavaScript创建回发. 使用ASP.Net和JavaScript强制回发 [
I wouldn''t say you are trying to do the impossible, more like you need to re-think the process.

What is the reason to call server code just to return to a JavaScript confirm? Can''t this be done on the client? If you need to compare values then use an ajax method.

Without seeing the resources you mention I would guess they are demonstrating using postback functional since they involve button events. You can create a postback from JavaScript at just about any time. Forcing a Postback using ASP.Net and JavaScript[^]


这篇关于ASP.net C#JavaScript确认-为什么这么难?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆