刷新只是一个div块 [英] Refreshing just a div block

查看:87
本文介绍了刷新只是一个div块的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

大家好,我是一个初级程序员,直接将其显示在一个< div>页面中,该网站显示了其显示的信息.与< p>在该div中,所有页面的布局都相同,因此有一种简单的方法可以基本上只是刷新< div>使用特定信息,而不是复制每个页面的布局并为每个信息集制作一个页面(例如,首页上的信息已打开,然后单击关于我们,我希望关于我们的信息显示在< div>块中无需创建一个全新的页面

任何帮助将不胜感激,谢谢
wes

解决方案

如果我对您的理解正确,请

使用母版页并将div放入其中.在这种情况下,所有继承母版页的页面都将具有div.因此,您无需将div放在所有页面中.

现在,您需要更新div的innerhtml.
如果div的内容经常更改,则需要将文本(如果需要,还可以连同html)存储到数据库中.

在master page_load中,检查您所在的页面,调用数据库并获取实际文本,然后将其分配给div.

您甚至可以使用ajax来执行此操作,但是如果仅在page_load中并且仅一次加载,则在这里使用ajax不会带来任何实质性的好处.



如果您的文本是固定的,则可以使用母版页中的隐藏字段使用某些定界符来存储所有页面的文本.因此,您无需往返服务器调用即可提高站点性能.尽管这种方法有弊端:如果文本太大,则无需通过将文本存储在隐藏字段中来使页面变重.我建议使用数据库进行持久存储.

另一种方法是将文本存储在自定义xml中.这是一种更好的方法.

希望这会有所帮助.
欢呼


使用JQuery进行AJAX调用并填充您的div.

此处 [ 解决方案

If I have understood you correctly,

Use master page and put the div inside that. In that case, all the pages that iherits the master page will have the div. So, you don''t need to put the div in all the pages.

Now, you need to update the innerhtml of the div.
If the content of the div is changed often, you need to store the text (along with html, if you need) to database.

In master page_load, check which page you are in, call the database and get the actual text and assign it in div.

You can even use ajax to do it, but if it is in page_load and one time load only, I don''t see any substantial benefit using ajax here.

OR

If your text is fixed, you can use hidden fields in master page to store the text for all pages using some delimiter. Thus you don''t need a round trip of server call and enhance site performance. Though this approach has cons: if your text is too large, no need to make your page heavier by storing text in hidden field. I would suggest to use database for persistent storage.

Another approach is to store your text in custom xml. This is a better approach.

Hope this helps.
cheers


Use JQuery to make an AJAX call and populate your div.

Here[^] is an example.


这篇关于刷新只是一个div块的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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