Showing posts with label scenario. Show all posts
Showing posts with label scenario. Show all posts

Wednesday, March 28, 2012

Change TimerControl Interval property without postback

Hi,

I have a "Live monitor" scenario, where data in UpdatePanel is being updated on TimerControl tick.

I want to give user an ability to change interval. It works fine, but postback is needed to do so.

Any way to do it without a postback?

(I'm new to atlas, so please excuse me if it's obvious.)

hello.

well, if you're ready to build your own timer, then it's possible to do that in the client side. currently, the problem is that the timercontrol generates a client behavior but doesn't generateou an id. due to this, you cannot get a reference to the behavior in the client side and do need to do a postback to refresh that interval.

Monday, March 26, 2012

Chanage button visibility if the button is outside of the UpdatePanel

Hello everyone,

Here is my scenario, and my problem.

I have a grid inside an UpdatePanel_1. The grid is populated after a Search button inside another UpdatePanel_0 is clicked (this is actually an user control and UpdatePanel_0 is inside the user control). This works fine.

I want to provide an Export button which exports the data from the grid to Excel, but want to show it only if the grid has any records.

If I add the button to UpdatePanel_1 the visibility toggling works fine, but when I click on the button I get the nasty message:

"Sys.WebForms.PageRequestManagerParserErrorException: The message received from the server could not be parsed. Common causes for this error are when the response is modified by calls to Response.Write(), Response filters, HTTP modules, or trace is enabled... "

And of course, I am using Response.Write for the Export of the grid to Excel.

If I put the Export button out of UpdatePanel_1, the Export works fine, but I cannot find a way to toggle the visiblity of the button. I set the visibility in the code behind when the grid has some records, but it doesn't seem to work (probably because the button is outside of the UpdatePanel_1).

What should I do to make the Exprot work and the button to appear only when I want it?

Thank you!

You could add the button to the UpdatePanelGridView and add an async trigger for the gridview databind event. So on databind, if gridview is empty your button will not show.


Hi Denis,

Thank you for your reply.

Setting the visibility of the button is not a problem when the button is inside the UpdatePanel. The problem in this case is that Export to Excel, which has to happen when the user pushes the button, doesn't work because of the error mentioned above (and the reason for the error is the Response.Write statement in the function below).

If I put the button out of the UpdatePanel, the Export to Excel works, but I have no control over the button's visibility, because it depends on the GridView records, which is inside an UpdatePanel.

Here is the function I use for the Export:

Public Sub ExportGridToExcel(ByVal grvBusinessAs GridView,ByVal pageAs Page,ByVal fileNameAs String)If grvBusiness.Rows.Count.ToString + 1 < 65536Then Dim twAs New StringWriter()Dim hwAs New System.Web.UI.HtmlTextWriter(tw)Dim frmAs HtmlForm =New HtmlForm() page.Response.ContentType ="application/vnd.ms-excel" page.Response.AddHeader("content-disposition","attachment;filename=" & fileName &".xls") page.Response.Charset ="" page.EnableViewState =False page.Controls.Add(frm) frm.Controls.Add(grvBusiness) frm.RenderControl(hw) page.Response.Write(tw.ToString()) page.Response.End()End If End Sub
I am still new to AJAX so little things like this are not easy to solve.Wink

Wednesday, March 21, 2012

CascadingDropDown Scenario!

Ok heres the deal, go the CascadingDropDown works on a simple aspx page but when I incorporate it into my MasterPages it fails with 12031 error code

Does the page has to derive from Page base class?

TIA

Hi,

Please make sure that the web method used by the cascadingDropDown can't be defined in masterpage, in this case, it can't be accessed from client side directly. Be sure to use a web service.

CascadingDropDown needs to fire "SelectedIndexChanged" from client-side

It seems I always end up with more questions than answers...

So...here's the scenario this time.

I've got two dropdownlists, Make (ddlMake) and Model (ddlModel) with a CascadingDropDownExtender attached to ddlModel. Obviously, when the user changes the Make, I need to retrieve the appropriate Models based on the selection. No problem, that part works just fine.

The twist is this: When I load this up into a ModalPopup, a record is going to (pardon the pun) drive what's being populated into ddlMake. I'm using Javascript to .show() my ModalPopup after I've looked up the record, so the code goes a little like this:

function showModal(object)
{
var _ddlMake = document.getElementById("<%= ddlMake.ClientID %>");
var _ddlModel = document.getElementById("<%= ddlModel.ClientID %>");

// Dummy for now, will be pulled from the loaded record
_ddlMake.options[4].selected = true;
_ddlMake._onParentChange(null,null);

var _popup = $find(object);
_popup.show();
}


Some of the posts I've seen suggested the _onParentChange(null,null), but Firebug is barking saying "_ddlMake._onParentChange is not a function". Granted, it's one of the internals of the CascadingDropDown, but others have stated that this is the way to do it.

What I'm wondering is how to do this. I can't believe that I'm the only person to have ever thought of needing to set/fire these events from the client-side. I'd love some help on this one, that's for sure!

Thanks in advance,

Ric

Bump...still needing some help...