Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
264 views
in Technique[技术] by (71.8m points)

c# - A modal popup with out using ajax, update panel, jquery or javascript- surprisingly this seems to work

After being exhausted with various post back and other issues related to modal popup ( ajax/jquery/javascript) we came up with a simple trick that seems to be working fine so far. We are to implement this in hundreds of other aspx files and we are afraid that this solution might come up with a issue in future so far not known to us. If some one can point out the potential issues we would really appreciate that.

On button click this is the code that fires up a pseudo popup: See this popup in action http://02e34b5.netsolhost.com/youtube/Zpopup.aspx

<asp:Panel ID="pseudopopup" runat="server" visible="false">
 <table style="position: fixed; z-index: 1; left: 0px; top: 0px"   border="0"  width="100%" height="100%">

// position fixed is essential. div wont extend 100% in height but an html table would
// no background color hence everything behind tbl is visible but NOT clickable 

    <tr>
        <td valign="top"  align="center" >

// this would put a nice center aligned div with css shadow helping give it a popup shape

        <div style=" width: 1000px;  margin-top:80px; padding:10px;  background-color: #FF00FF" id="layer2" class="roundshadow">
        Grid goes here
                 Form view goes here
                other stuff goes here
                no need to worry about the postback

             close button goes here that makes the panel visible = false

 </div>
        </td>

    </tr>
    </table>
   </asp:Panel>

This has been so far working with out any issues. See this popup in action http://02e34b5.netsolhost.com/youtube/Zpopup.aspx

See Question&Answers more detail:os

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)

It will work of course, but with some ifs. As a pure server-side method, this has all the cons and pros of such an approach.

pros:

  • Easier to implementation. No worries about the client scripts.
  • Anything you need is available on the server-side. You won't need to make additional requests to acquire data from the server.
  • Has no script compatibility issues, works on any browser.
  • No need to learn Javascript. The server-side language (c#, VB) will be enough
  • No need to learn HTML DOM or any additional client-side frameworks. Just asp.net

cons:

  • Postbacks are expensive and consume a lot of resources on the server. This will become a serious problem when the number of concurrent requests grow. You will have to employ a resourceful web server (better CPU, more RAM, more powerful Network connection, ...)
  • This is slower than a client-side popup window because of the round-trip to the server.
  • The user can't "play" with this dialog. Actions like moving, resizing, keeping fixed, ... are practically impossible.
  • As the page grows, you will face the problem of ViewState which makes the pages huge.
  • This is an out-of-date solution. Nobody likes it anymore and people (users and coworkers) will begin to shout at you for implementing something like this.
  • If the server needs any data from the client-side (window size, ....), you should send them along with your request.

Conclusion:

  • Use this approach only if you have an Intranet site with low traffic and few users.
  • Never use it for a real-world Internet web site.

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...