Free Support Forum - aspose.com

A few questions on Ajax and CustomCommandButtons

Hi, I had a couple of questions. We are a registered ASPOSE user and originally bought the component to do exports to Excel on the backend, which is great and working fine so far. However, what helped push my boss to commit to buy this was the webgrid. I had a couple of questions on the webgrid.

1) I know it’s fairly easy to create a new context menu item or button that makes a server call.

CustomCommandButton c = new CustomCommandButton();
c.CommandType = CustomCommandButtonType.CommandButton;
c.Command = “EXPORT”;
c.Text = “Export to Excel”;
c.ImageUrl = @"./acw_client/excel.gif";
GridWeb1.CustomCommandButtons.Add©;
c = new CustomCommandButton();
c.CommandType = CustomCommandButtonType.ContextMenuItem;
c.Command = “CUSTOM1022”;
c.Text = “Custom Menu Item Text here”;
GridWeb1.CustomCommandButtons.Add©;

Is there a way to attach a client-side script to any of these items/command buttons?

2) When I enable AJAX on the GridWeb control it makes a call like this

http://localhost:3764/MyPage.aspx/acw_ajax_call?gid=GridWeb1

And from fiddler, I can see it is sending this

Name: GridWeb1_XMLDATA
Value: <DATA><CELLS><C ID=“1#3” V=“15” S=""/></CELLS></DATA>

What I can’t get is how in ASP.Net I retrieve this on a server side. It doesn’t seem to call page load or anything else…what events is it calling and how do we hook into it?

(I can read the headers once I figure that out.)




Hi,<?xml:namespace prefix = o ns = "urn:schemas-microsoft-com:office:office" />

Thank you for considering Aspose.

1. To attach command buttons with client-side script:

First, register the client script function onGridInitClient to the OnGridInitClientFunction of GridWeb. The html code like this: OnGridInitClientFunction="onGridInitClient".

Second, insert the client script function code into aspx.

<script language=javascript>

function onGridInitClient()

{

var cmdButton = document.getElementById("GridWeb1_CCMD");

cmdButton.attachEvent("onclick", onCmdButtonClick);

}

function onCmdButtonClick()

{

window.alert(event.srcElement);

event.cancelBubble = true; // if you want to cancel current event, add this line.

}

</script>

2. To hook <?xml:namespace prefix = st1 ns = "urn:schemas-microsoft-com:office:smarttags" />Ajax request URL, override ProcessRequest method in your page class. You can get Request object from context object.

public override void ProcessRequest(HttpContext context)

{

base.ProcessRequest(context);

}

Thank You & Best Regards,