使用 jQuery 就地编辑 ASP.NET 母版页
您好,我正在尝试获得就地编辑功能。但这次它位于 ASP.net 应用程序的母版页中。我在母版页上有一个标签控件(用于每个网页的标题)。在我的内容页面中,我想允许用户编辑该标题。 场景是当用户单击标签时,标签应转换为文本框。编辑,然后当文本框失去焦点时,应将其转换为更新的标签。我不想更改我的母版页内容。否则我可能可以在主页上添加一个隐藏的文本框以用标签替换它。但我担心的是,我可以在不编辑母版页的情况下执行此操作吗?我尝试使用 JQuery .replaceWith()
方法。但我对 JQuery 和 asp.net 很陌生。请帮助我,谢谢。
我尝试了斯蒂芬的解决方案,但出现对象不支持Javascript运行时错误。 JS 代码给出为:
<script type="text/javascript" src="../Scripts/jquery-1.4.2.min.js" ></script>
<script type="text/javascript" src="../Scripts/jquery-1.3.2.min.js" ></script>
<script type="text/javascript" src="../Scripts/jquery/jeditable.js" charset="utf-8"> </script>
<script type="text/javascript">
$(document).ready(function() {
$(".click").editable("~/AdminArea/Setup/SetupFixedText.aspx", {
tooltip: "Click to edit...",
style: "inherit"
});
});
</script>
在 aspx 中,我首先有一个标签,我将 calss 分配给标签,但现在将标签放在“b”中,
div id = 'lblcontent'
h3 class="BlueHeading"
b class="click" style="display: inline"
asp:Label ID="lblContentTitle" runat = "server" EnableViewState="False"
/asp:Label
/b
/h3
/div
我删除了尖括号,因为该编辑器将其视为 html。
Hi I am trying to get the inPlace editing functionality. But this time its in Master page of an ASP.net application. I have a label control (for title of each web page) on master page. And in my content page I want to allow user to edit that title.
Scenario is that Label should be converted to textbox when user click label. edit and then when textbox will loose focus, it should be converted to updated label. I don't want to change my master page contents. Otherwise may be I can add a hidden textbox on masterpage to replace it with label. But my concern is that Can I do this without editing my master page? I tried to work with JQuery .replaceWith()
method. But I am new to JQuery and asp.net. Please help me thanks.
I tried stephen's solution but getting object not supported Javascript runtime error. JS Code is given as :
<script type="text/javascript" src="../Scripts/jquery-1.4.2.min.js" ></script>
<script type="text/javascript" src="../Scripts/jquery-1.3.2.min.js" ></script>
<script type="text/javascript" src="../Scripts/jquery/jeditable.js" charset="utf-8"> </script>
<script type="text/javascript">
$(document).ready(function() {
$(".click").editable("~/AdminArea/Setup/SetupFixedText.aspx", {
tooltip: "Click to edit...",
style: "inherit"
});
});
</script>
And in aspx I have a label first I assigned calss to label but now have placed label in "b"
div id = 'lblcontent'
h3 class="BlueHeading"
b class="click" style="display: inline"
asp:Label ID="lblContentTitle" runat = "server" EnableViewState="False"
/asp:Label
/b
/h3
/div
I removed angle brackets as this editor takign it as html.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
对于使用 jQuery 进行 InPlaceEditing,您应该查看此插件...
http://www.appelsiini.net/projects /jeditable
应该让事情变得更容易
编辑给定的发布代码
将您的 aspx 页面更改为:
For InPlaceEditing with jQuery, you should check out this plugin...
http://www.appelsiini.net/projects/jeditable
Should make things a lot easier
EDIT Given Posted Code
Change your aspx page to this: