Hi,
Sorry for the subject but I couldn't simplize the problem for subject.
I have a WebDataGrid and with your tutorials I've added context menu to grid. After right-click and selecting an item from grid, I post id of that row to WebMethod. After that I want to pull some data and fill my WebDialogWindow with this and make it's WindowState normal. Eventually the problem starts here. WebMethod does not allow to access controls on my page due to being static. I couldn't find a workaround. Please help.
I've attached snippets.
Hey Kerem,
Thank you for your patience!
I have tried to reproduce this access issue, although I couldn't. Below you will find a sample that is implementing the exact scenario. I have a WebDataGrid with WebDataMenu which is used as a context menu, and on first item click I call a WebService/GetData WebMethod which is returning a simple string. That string is passed as a content to a DialogWindow.
Could you please have a look at the sample and let me know what I am missing from your scenario. I hope that you will find the sample helpful.
Code snippet:
<script id="igClientScript"> function GridMouseDown(grid, eventArgs) { var menu = $find("<%= this.WebDataMenu1.ClientID %>"); var targetElement = eventArgs.get_browserEvent().target; var selectedRow = grid.get_behaviors().get_selection().get_selectedRows().getItem(0); var currentlySelectedRow = eventArgs.get_item().get_row();
if (eventArgs.get_item() == null || !eventArgs.get_item().get_row) { return; }
menu.showAt(null, null, eventArgs.get_browserEvent()); }
function getData(sender, eventArgs) { if (eventArgs.getItem().get_key() === "miRun") { $.ajax({ type: "POST", url: "WebService.asmx/GetData", data: "{}", contentType: "application/json; charset=utf-8", dataType: "json", success: function (response) { var data = response.d; var $dialog = $find("wdw1"); $dialog.show(); $($dialog.findChild("content")).html(data); }, error: function (response) { console.log(response); } }); } }</script>
WebService:
[System.Web.Script.Services.ScriptService]public class WebService : System.Web.Services.WebService {
public WebService () {
//Uncomment the following line if using designed components //InitializeComponent(); } [ScriptMethod(ResponseFormat = ResponseFormat.Json)] [WebMethod] public string GetData() { return "Some data"; }}
Looking forward to hearing from you.
Hello Kerem,
Thank you for contacting us,
I wanted to let you know that I am currently investigated that issue and will contact you tomorrow with my findings.