简体   繁体   English

如何从代码隐藏传递对象以填充JQuery UI控件

[英]How do i pass an object from codebehind to populate a JQuery UI control

So I am new to using jquery and asp.net webforms together. 所以我是一起使用jquery和asp.net Webforms的新手。 The idea is that i will have a repeater, on a webform page, populated by data from a database. 我的想法是,我将在Webform页面上有一个中继器,该中继器由数据库中的数据填充。 Now i want this repeater to have an edit button which will open a jquery ui dialog with textboxes, and the data from the repeater should populate the jquery ui dialog controls. 现在,我希望此转发器具有一个编辑按钮,该按钮将打开带有文本框的jQuery UI对话框,并且来自转发器的数据应填充jQuery UI对话框控件。 How do i send data back and forth from both ends. 如何从两端来回发送数据。 Any sample code will be much appreciated. 任何示例代码将不胜感激。

Thanks you 谢谢

I have a rough plan , to achieve this. 我有一个粗略的计划,要实现这一目标。

  1. Use repeater to show data , lets say you have firstname, userid (assumption: this is the primary key) etc. Add a button called edit in repeater template. 使用转发器显示数据,假设您具有名字,用户名(假设:这是主键)等。在转发器模板中添加一个称为“ edit的按钮。
  2. Write a JS say (EditUser), and attach that js function to edit button. 编写一个JS语句(EditUser),并将该js函数附加到edit按钮。 And pass the firstname and userid to EditUser JS function. 并将firstnameuserid传递给EditUser JS函数。
  3. Have a hidden field, to store userid that is passed to EditUser . 有一个隐藏字段,用于存储传递给EditUser userid
  4. EditUser will bring jQuery dialog, also it will show the firstname in textbox as editable field. EditUser将显示jQuery对话框,还将在文本框中显示名字作为可编辑字段。
  5. Write a WebMethod , use ajax to post userid stored in hidden field and newly modified firstname to webmethod . 编写一个WebMethod ,使用ajax将存储在隐藏字段中的userid和新修改的firstnamewebmethod

Webmethod - Server code written in code behind, can be callable via ajax . Webmethod-用后面的代码编写的服务器代码,可以通过ajax调用。 Help - http://www.aspsnippets.com/Articles/Calling-ASPNet-WebMethod-using-jQuery-AJAX.aspx 帮助-http: //www.aspsnippets.com/Articles/Calling-ASPNet-WebMethod-using-jQuery-AJAX.aspx

  1. In webmethod, write code to take userid and changed value, save to DB. 在webmethod中,编写代码以获取userid和更改的值,然后保存到DB。
  2. On ajax callback, actually update that value in repeater ( you need some jquery selector logic to fetch that control and set value). 在ajax回调上,实际上在转发器中更新该值(您需要一些jquery选择器逻辑来获取该控件和设置值)。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 如何从代码隐藏访问用户控件的公共属性? - How do I access a public property of a User Control from codebehind? 如何将代码隐藏值传递给Gridview UI的HeaderTemplate标签控件 - How to pass codebehind value to HeaderTemplate label control of Gridview UI 如何从代码隐藏中在用户控件的内容控件中的数据模板中启动故事板? - How do I start a Storyboard in a Data Template in a Content Control in a User Control from codebehind? 如何访问代码隐藏 object 中的公共变量以进行 ascx 控件? (内联表达式) - How do I access a public variable in the codebehind object for an ascx control? (Inline Expression) 我如何将数据从Codebehind填充到ascx文件 - How could I populate data from codebehind to ascx file 如何从EF中的ViewBag填充jquery ui选择列表? - How do I populate a list of jquery ui selectables from a ViewBag in EF? 如何引用 HTML 的输入<textarea>控制代码隐藏? - How do I reference the input of an HTML <textarea> control in codebehind? 如何将类模型/对象从代码隐藏传递到 aspx 页面? - How to pass a class model/object from codebehind to aspx page? 从代码隐藏触发jQuery ui对话框? - trigger jQuery ui dialog from codebehind? 如何从后台代码返回字符串并显示在网页上? - How do I return string from codebehind and display on web page?
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM