Showing posts with label browser. Show all posts
Showing posts with label browser. Show all posts

Wednesday, March 28, 2012

TreeView and update panel

I am creating a browser for a large document management system, modelled on the way windows explorer works.

So: ... I have a TreeView providing a view of the folders for which I am populating the child nodes on demand when a node is expanded or clicked. (The original method of populating the whole TreeView was impractical since it took several minutes to return and often timeout!)

At the same time, if a node is clicked, I show a list of the documents in that folder.

I can get this working, but somewhere along the way, the client stops working and the TreeView click event stops firing.

Is this a known issue or do you think I am asking too much of the framework?

I have since abandonded Atlas for this and am currently living with a long blank screen between page refreshes, which I think is totally useless for user experience.

Sorry not an immediate answer, but I would also be interested in anybody else's take on this.

I will trying to build more or less the same thing over the next couple of days (for an online content management system) so I'll get back to you then on it (successful or not!), but no I don't think it's asking too much, it's a perfectly logical use of it!


Coming back to this post.. .

How have you implemented the TreeView - just that it is supposed to implement client call back as part of the control so you shouldn't need to have blank screens and whole page refreshes - possibly a pause before expanding if it's big - but no blank screens?

I've just dropped it into my content management system, and while it's not pure Atlas, it seems to work fine using the client call back? Probably I'm missing something as only just started playing with Atlas.

Saturday, March 24, 2012

Trigger wont cause a PostBack (Inside UpdatePanel)

When I click my LinkButton inside my GridView I want the page to postback and a pdf to be streamed to the browser.
It is streamed but the page dont Post so nothing is received.

What am I doing wrong here?

1Protected Sub GridView1_RowDataBound1(ByVal senderAs Object,ByVal eAs System.Web.UI.WebControls.GridViewRowEventArgs)Handles GridView1.RowDataBound23If e.Row.RowType = DataControlRowType.DataRowThen45Dim ptAs New PostBackTrigger()67pt.ControlID = e.Row.FindControl("lbtnPrintInvoice").UniqueID8UP1.Triggers.Add(pt)910End If1112End Sub

Hi,

in docs:

http://asp.net/AJAX/Documentation/Live/mref/T_System_Web_UI_PostBackTrigger.aspx

Remarks

Use thePostBackTrigger control to enable controls inside anUpdatePanel to cause a postback instead of performing an asynchronous postback.

Use theRegisterPostBackControl(Control) method of theScriptManager control to programmatically register a postback control. You can then call theUpdate() method of theUpdatePanel control when the trigger control performs a postback.

note

Programmatically addingPostBackTrigger controls is not supported.

So basically you need to use ScriptManager's RegisterPostBackControl method to do it.


Hmm I can apreciate that but how do I call my lbtnPrintInvoice inside Gridview1 thats the question... The below code doesnt work for some reason ;)

1<Triggers>2<asp:PostBackTrigger ControlID="lbtnPrintInvoice" />3</Triggers>

Gives the error:

A control with ID 'lbtnPrintInvoice' could not be found for the trigger in UpdatePanel 'UP1'.


You really read the previous reply?Big Smile

Does this help:

Protected Sub GridView1_RowDataBound1(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewRowEventArgs) Handles GridView1.RowDataBound

If e.Row.RowType = DataControlRowType.DataRow Then

ScriptManager.GetCurrent(Me).RegisterPostBackControl(e.Row.FindControl("lbtnPrintInvoice"))

End If

End Sub

-- EDIT: Fixed this reference in the code


Jeeze! I wans't aware you could actually call the scriptmanager like that since mine is in the masterpage I never thought I could adress it directly

Thanks a bunch for the solution though for people that might want the complete solution I added the page reference in the below code as well.

1Protected Sub GridView1_RowDataBound1(ByVal senderAs Object,ByVal eAs System.Web.UI.WebControls.GridViewRowEventArgs)Handles GridView1.RowDataBound23If e.Row.RowType = DataControlRowType.DataRowThen4ScriptManager.GetCurrent(Me).RegisterPostBackControl(e.Row.FindControl("lbtnPrintInvoice"))5End If67End Sub

Oh and I also tried to do it in RowCreated, never would have worked out.


ScriptManager has good utility methods. It's worth to know about them. I edited & corrected the code. Made a typo as I typed directly to the post.

Wednesday, March 21, 2012

Trying to open a new browser window from within an UpdatePanel and getting Sys.WebForms.Pa

I'm in the process of developing a module for a DotNetNuke portal site. The module hosts an ASP2.0 Wizard control which guides the user through report & parameter selection & then when the Finish button is clicked the module opens a new browser window at a url which hosts the ASP2.0 ReportViewer control.

This all worked OK until I enable AJAX on the site. I've wrapped the Wizard control in an UpdatePanel and although the functionality of the wizard is fine when the Finish button is clicked I get the error"Sys.WebForms.PageRequestManagerParserErrorException: The message 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, HttpModules, or server trace is enabled."


The wizard_FinishButtonClick handler is doing some housekeeping then calling Response.Write() with a JavaScript string to open the new browser window so I'm guilty as charged. I've tried using DNN's Intermodule Communications to get another module to kick off the browser open but I still end up with the same exception. What would be the best way of getting around this issue ?


ThanksScott

The Wizard control is not supported by Ajax... along with a few other controls... You can work around it by wrapping your Wizard into a Iframe but not within a update panel...


To nitpick, the Wizard controlis supported within an UpdatePanelas long asits contents are converted to an editable template.

Seehttp://ajax.asp.net/docs/overview/UpdatePanelOverview.aspx#UpdatePanelCompatibleControls.


Thanks for your responses guys but I don't think the interaction of the Wizard and UpdatePanel is the issue.

The reason the wizard was wrapped by an UpdatePanel was that

1) the wizard is wrapped by a Drag panel and a collapsible panel. The functionality of the Drag & Collapse panels works fine but any activity within the wizard generates a postback that resulted in the whole thing being relocated back to it's initial start point.

2) I then added the UpdatePanel and I can now move the panel around the page and do stuff within the wizard without it relocating to start point.

3) It was at this point that I started to get the error which is caused by the Response.Write when the wizard Finish button is clicked. There is another method called when the Finish button is clicked and this functionality still works it's just the Response.Write I need to avoid.

I'll be more specific this time - is there a way to open a new browser within an update panel ?

Regards
Scott


Well it seems it is possible to do this. All I had to do was use the script manager to register a client script block from the Finish button click event handler.

the code for this would be for example

protected void wizReport_FinishButtonClick(object sender, WizardNavigationEventArgs e)
{
try
{
string reportViewerUrl = System.Configuration.ConfigurationManager.AppSettings["ReportViewerUrl"].ToString();
System.Type cstype = typeof(class name);
string csname = "PopUpReport";
string script = @."window.open('" + reportViewerUrl + "','_blank','location=no,scrollbars=yes,resizable=yes,top=0,left=0,height=800,width=950');";
ScriptManager.RegisterClientScriptBlock(wizReport, cstype, csname, script, true);
}
catch (Exception x)
{
string s = x.Message;
}
}