Showing posts with label table. Show all posts
Showing posts with label table. Show all posts

Monday, March 26, 2012

UpdatePanel & DHTML/.htc behavior

Hoping for the final piece of my ATLAS jigsaw here...

I have a WebControl that builds a table and uses the onDocumentReady event to make it scrollable, with the code in an htc file, referenced in the behavior section of the css of the table.

My WebControl works perfectly with the ATLAS UpdatePanel, and will scroll as expected when first loaded. However - upon a callback to sort the data etc, as the onDocumentReady event will not be fired when the UpdatePanel refreshes, the DHTML doesn't get triggered, and nothing gets applied to the table in the control.

Does anyone (please) have experience, or know how, of using a control in an ATLAS UpdatePanel, that allows the DHTML to be executed (e.g. through an alternative to onDocumentReady) on callback, as it would be usually on PostBack?

Thanks in advance!

Hi,

There is no specific event for this today, but I have logged your suggestion as part of some new work we hope to be doing to UpdatePanel.

Thanks,

Eilon

Saturday, March 24, 2012

UpdatePanel and database

Hi there.

Is it possible to use UpdatePanel with SqlDependency to update a gridview or other bounded control whenever a row is added to a table? Or the update panel triggers collection only works with controls?

Thanks in advance,
P. Conde

Hey Pedro,

About a year ago I responded to two posts regarding the same kind of topic you are talking about. Currently there is not implementation inherent to ASP.NET to accomplish your scenario. I myself was also looking to accomplish what you were trying to do as well.

The only solution that I could come up with is the solution I have listed in the following links. I have recently implemented this solution in a Proof-Of-Concept (POC) kind of way. There are server technologies out there that are not .NET and support server push technology. Specifically do a search on google for "Comet" it's a phrase that was coined by one of the creators of the DojoToolkit. Also check out Meebo.com they have a great example of implementing a service with no page refreshes simply data pushing.

The only thing I left out in the posts below was that in order to get the flash client to connect you have to put a crossdomain.xml on the server in the root inetpub folder (wwwroot).

Other than that I have implemented the Windows service to listen on a specific port, and flash connects from the browser to the server and port and passes and receives XML. Then through the External Interface it can update the page. The Windows Service can listen on a SqlCommand with the SqlDependency object for changes in the current query.

You could use the SqlDependencyCache object but that would only work for when you do a postback. All it does is invalidate the cache so that the data has to be loaded from the Sql Server again. Anyhow good luck with you project.

The Solution
http://forums.asp.net/thread/1366004.aspx
SqlDepedency Question
http://forums.asp.net/thread/1336290.aspx

JoeWeb


I have set all the SqlDependency issues and I can see by debugging that it is workin when a table changes (row inserted/deleted/...). I'm using an event in a webusercontrol as a trigger for the update panel. Even if I use label or textbox controls getting some data in a sql database, the asyncpostback doesnt work... If I use a button at the updatepanel and click on it, the grid is updated...

I have seen the video "#4 | How Do I: Implement Dynamic Partial-Page Updates with ASP.NET AJAX?" and I'm following the leads in it... Shouldn't this be working?!

Anyone has solution for this?!

P. Conde


As I have previously stated this is not possible. The best possible solution would to be implementing a custom solution.

The SqlDependency object sets up an new Notification Stored Procedure along with a Service Broker to channel the request back to the client.

However in an HTTP scenario the Service Broker cannot invoke a page refresh... and therefore it is "IMPOSSIBLE" to make this a viable solution. HTTP doesn't allow there to be a server push without it being hosted on a server that has "Comet" technology. Again your best bet is to implement a custom solution.

Even though it's wrapped in Ajax it doesn't mean it keeps an open connection... it's still doing a postback when you hit that button.

Good Luck!
JoeWeb

UpdatePanel and Dynamic populated table

My control builds a table dynamically [some subscription rows]

The table is placed inside and update panel:

<atlas:UpdatePanel ID="upBrowse" runat="server" Mode="Conditional" RenderMode="Inline"> <Triggers> <atlas:ControlEventTrigger ControlID="btnDelete" EventName="Click" /> <atlas:ControlEventTrigger ControlID="btnOK" EventName="Click" /> </Triggers> <ContentTemplate> <asp:Table ID="tblSubscriptions" runat="server" CellPadding="1" CellSpacing="1" Style="position: relative" BorderColor="Black" BorderStyle="Solid" BorderWidth="1px" EnableViewState="true"> </asp:Table> <br /> <asp:Button ID="btnAdd" Text="Add" runat="server" OnClick="btnAdd_Click" /> <asp:Button ID="btnDelete" Text="Delete" runat="server" OnClick="btnDelete_Click" /> </ContentTemplate> </atlas:UpdatePanel>

When the table gets populated, there is a checkbox for each row to select the subscriptions to be deleted.

There is a Delete Button and the task is to select all the checked rows and delete them.

My problem is that on the trip back, handling the delete button 'btnDelete_Click' I cannot iterate the table programmatically because there are no rows:

foreach (TableRow rowin tblSubscriptions.Rows) --> no rows

What is wrong?

Thx,

Uri

Can you show a some code how you add dynamic rows? Just as an idea - maybe HtmlTableRow instead TableRow? You can use Repeater with checkboxes instead your table, and you will receive selected values in the Form collection...
foreach (Subscription oSubin oSubscriptions) { count++;if ((int)oSub.GetFieldValue("SystemID") == _systemId) { TableRow row =new TableRow();if (bInStyleAlt) { row.ApplyStyle(styleAlt); bInStyleAlt =false; }else { row.ApplyStyle(styleNormal); bInStyleAlt =true; } CheckBox box =new CheckBox(); box.ID ="chkSub_" + oSub.SubscriptionId; box.Checked =false; TableCell cellChk =new TableCell(); cellChk.Controls.Add(box); row.Cells.Add(cellChk);

Interesting points:

I am able to manipulate other elements inside the update panel (like textboxes) if these are not inserted dynamically.

Let me try HtmlTableRow or the repeater

UpdatePanel and FileUpload

Hi,

i have wide customer table that i handle with a big DetailView nested inside an UpdatePanel for faster interaction. Works like a charm.

Now they ask me to allow the user to upload a file, but when i add it in the detail view and i save data i get no file at all, as if putting it into an updatepanel do not allow him to send the file any more.

Is there some setting i have to put so to make it work ?

thanks in advance,

Fabrizio

Hi There,

This is a known ** not sure should call it issue, but callback will not work for FileUpload ( e.g. have fileupload in updatepanel )

The trick is assign postbacktrigger to the button that upload the file.

Example:

<asp:ScriptManagerID="ScriptManager1"runat="server">

</asp:ScriptManager>

<asp:UpdatePanelID="UpdatePanel1"runat="server">

<Triggers>

<asp:PostBackTriggerControlID="Button1"/>

</Triggers>

<ContentTemplate>

<asp:FileUploadID="FileUpload1"runat="server"/>

<asp:ButtonID="Button1"runat="server"Text="Button"OnClick="Button1_Click"/>

</ContentTemplate>

</asp:UpdatePanel>


Hi,

Thanks for your help, after posting i found other posts on the problem, for future references i add here another help to the problem of the button not sending the file on the first click.

try to use this

in Form tag add this

enctype="multipart/form-data"

example:

<form id="form1" enctype="multipart/form-data" runat="server">

i use that and it works

As inhttp://forums.asp.net/t/1060363.aspx?PageIndex=2


Thank you! I've been fighting with this for a week!
Thanks for the tip!!!!