我在表中有一个数据网格,并且在数据网格的每一行中都有一个超链接,该超链接允许用户导航到某个页面或停留在当前页面.另一方面,我的超链接在sql请求中执行计数",如果sql请求返回的数字大于15,则将您导航到第二页,否则,将其导航到10至15之间确认消息(如果单击确定",则将导航到另一页,否则将停留在当前页面),否则将显示一条消息,表明您无法导航到另一页.
Hi, i have a datagrid in my table and in each row of the datagrid i have an hyperlink that allows a user to either naviguate to a certain page or stay in the current page. in other hand, my hyperlink do a "Count" in sql request, and if the number returned of the sql request is superior to 15, it navigates you to a second page, else if it''s between 10 to 15, it shows you a confirm message (if you click "ok" then you will navigate to the other page, else you will stay in the current page), else it shows you a message that shows you that you can''t navigate to the other page.
推荐答案solution1很好,在这里我向您解释如何在页面方法后面添加代码并在javascript中使用它: 这是您的代码背后: the solution1 is good and here I explain to you how to add to your code behind a page method and use it in javascript: here is your code behind: [WebMethod] [ScriptMethod] public static int getSqlCountAjax() { //write your code here for this method }
然后使用脚本管理器并启用pagemethod属性:
then use script manager and enable pagemethod property:
function validateLink() { PageMethods.getSqlCountAjax(onRequestComplete, onError); // call to yr AJAX function to get sql count function onRequestComplete(result) { var sqlCount = result; if (sqlCount > 15) { return true; } else if (sqlCount >= 10 || sqlCount <= 15) { if (confirm('yr confirmation mesaage here...') == 1) { return true; } } else { alert('not allowed to navigate to this page'); return false; } return false; } }
单击此处 剧本 函数validateLink(){ var sqlCount = getSqlCountAjax(); //调用yr AJAX函数以获取sql count if(sqlCount> 15){ 返回true; } 否则if(sqlCount> = 10 || sqlCount< = 15){ if(confirm(''yr确认消息在这里...'')== 1){ 返回true; } } 其他{ alert(``不允许导航到此页面''); 返回false; } } 问候 尼拉·索尼(Nial Soni) click here Script function validateLink() { var sqlCount = getSqlCountAjax(); // call to yr AJAX function to get sql count if(sqlCount >15) { return true; } else if(sqlCount >= 10 || sqlCount <=15) { if( confirm(''yr confirmation mesaage here...'') == 1) { return true; } } else { alert(''not allowed to navigate to this page''); return false; } } Regards Niral Soni
更多推荐
单击按钮后显示特定的确认消息
发布评论