在Web应用程序中由c#.net提示 [英] prompt by c# .net in web application

查看:80
本文介绍了在Web应用程序中由c#.net提示的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨 如何在Web应用程序中不使用任何dll的情况下通过c#.net在Web应用程序中将div提示为对话框并且可以获取响应,并基于响应(覆盖/附加/忽略)可以继续执行由if-else维护的代码. />
在此先感谢您

Hi how I can Prompt div as dialog by c# .net in web application without using any kind of dll and can get response and based on response (Overwrite/Append/Ignore) can continue execution of code which is maintained by if-else.

thanks in advance

推荐答案

,您首先需要了解ASP.NET中的客户端-服务器"进程如何工作.

1-仅客户端请求,服务器仅服务.记住HTTP协议.

2-客户端是HTML + Javascript.因此,您要在客户端上显示的任何内容都必须转换为客户端的标准
ASP.NET中的自定义Javascript对话框 [
you first need to understand how Client-Server process in ASP.NET works.

1- Client requests only and Server serves only. remember HTTP protocol.

2- Client is HTML + Javascript. Hence whatever you want to show on client must be converted to client''s standard
Custom Javascript Dialog in ASP.NET[^]

3- Server is c# asp.net.
Most common impression is people treat web application as procedural language like winform application, you click a button.. button click event will be raised .. in click method user will popup some message and so on.

But it is not like that. its like this:
1- user requests a page like: http://www.somewebsite.com/home.aspx with some header information like browser type/version etc.
2- IIS gives this to Asp.net and asp.net checks there is nothing else in request i.e. no querystring and no form elements that means it is requested first time. (remember IsPostBack)
3- asp.net reads the home.aspx file and create a dll adding some more lines to create instance of Web.Page class.
4- Then the home.aspx.cs as dll comes into the picture and initializes all of its controls.
5- finally every control is rendered that means HTML and Javascript is created for client end, and send.
6- user clicks on a asp;button in browser. The browser will send request back to home.aspx but this time with Form and its element + the object who triggered the event i.e. button clicked
7- IIS gives this to ASP.net and because this time the request has form also it creates Reqeust object with form/querystring elements and adds it to HttpContext so that user can access all of its elements.
8- when home.aspx.cs comes into the picture it initializes all of its controls and after page load event it checks for any event raiser information and binds the event to asp:button control at server side and then button raises the event.
9- when all code statments in button_click methods are completed the page process rest of the events and unload itself and finally sends its rendered html to client. Now if you want to send anything from button_click method you need to add it to Response objects output property and then Response.flush/end. But the dll will its no more in picture go asp.net will unload the page and its dll and send the response to client.

The AJAX gives you feel of async process but it works on HTTP.

so you need to keep all the point in mind and then design your functionality.

For example in your case:
1- Add some javascript function say ShowWindow() and on click of some button invoke it.
2- ShowWindow will show your custom dialogbox at client end and clicking of any button inside it set some value in hidden field and submit the page back to server.
3- in button click method add your code based on the value in hidden field.

Thanks,
Hemant


这篇关于在Web应用程序中由c#.net提示的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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