Showing posts with label ive. Show all posts
Showing posts with label ive. Show all posts

Wednesday, March 28, 2012

Update UserControl from another UserControl in an UpdatePanel

I've got 2 usercontrols on my webpage (let's call them uc1 and uc2). In uc1 is a button. When I click on the button I bubble up the event to the main page. In the main page I handle the event. In the event handler on the main page I set a property of uc2 which sets the text of a label in uc2. I want this interaction to happen in an UpdatePanel so that the screen doesn't postback, but I can't seem to get it to work. Any direction would be greatly appreciated. I have a sample app if someone wants to see it.

Hi

I use that technique in nblogr. You can download nblogr's source from codeplex.

Basically you expose a method in your uc2 something like void DoUpdate()
And in that method you call myUpdatePanelID.Update()

and that should do the trick

Hope this helps you a little


Thanks so much! That did the trick!

Could you be a bit more specific? I downloaded that code but there is a lot of code there. Looking for a snippet....

Thanks.

Jeff


What part are you having trouble with? Bubbling up the event from the first control and modifying the second one, or having the UpdatePanel refresh after the changes have occurred?

I was having a similar issue. I've got two controls in two separate panels on one page and I'm using the event bubbling to get the two controls to communicate and toggle their visibility. I was forced to click the first control's button twice before the intended result would take place, even though all the code would execute while debugging. It seemed the first click wasn't updating the client but the second one did. Then I took a closer look at my container page, I didn't have the two controls in an UpdatePanel, even though the container page was setup for ajax. Wrapping the all the controls and panels in an UpdatePanel got it sorted.

Just thought it would be useful to note here.

-jason


Hi, What i have done in my application is like i have a combo inside a usercontrol , another control includes

a login page type controls , Now when ever the user selects any thing from the combo control the text on the login control also changes without full page refresh. If this is your prob. then below is how i did it.

Put your combo control inside UpdatePanel and contentTemplate tag. Dont do any thing with login control just put both of them on aspx page inside a Scriptmanager tag. and on page load of Login control put your logic . If this is not sufficient then i can send you the code .

Can you tell me how to stop the mail of Posts from this site to my mail box, or how to unsubscribe. becoz this thing has filled my personal ID.

Shrikant

UpdatePanel - Javascript to create control wont fire

I've got an update panel that functions like tabs, hiding/showing certain controls. One of the controls is rendered via javascript:

<script type="text/javascript" language="JavaScript">
showCategoryBox("Databases", "All Resources");
</script>

This creates a dropdown list to choose from. It works fine when the page loads, but going to other tabs, then coming back to this one causes it to disappear. All of the standard html controls show up fine, but it won't execute this script to create the dropdown.

Any Ideas? Thanks

Coop

Try something like this. The pageLoaded event of the PageRequestManager is raised after every postback, synchronous or asynchronous.

<script type="text/javascript">
var prm = Sys.WebForms.PageRequestManager.getInstance();
prm.add_pageLoaded(onPageLoaded);

function onPageLoaded(sender, args) {
showCategoryBox("Databases", "All Resources");
}
</script>


Thanks. I tried this (and something very similar by using ScriptManager in the cs file) and it just basically only shows this drop down, nothing else on the page shows up. The page starts to render, then everything goes blank and only this shows up at the top.

Monday, March 26, 2012

UpdatePanel & UpdateProgress

Hello, I've an updatepanel with a datalist, and an updateprogress with a gif animation. I need that when i do an asynchronous postback, the content of the updateprogress replace the whole content of the update panel. I don't know, how to do that... any idea please?

I'm waiting for your reply... thanks....

Nicolás.

Give this approach a try:http://blogs.visoftinc.com/archive/2007/09/10/modalupateprogress.aspx

The update progress is displayed like that of a modal window like the AJAX modal popup displays (http://www.asp.net/AJAX/Control-Toolkit/Live/ModalPopup/ModalPopup.aspx).\

-Damien


Thanks Damien, your answer was of great help.

Nicolás.


Thats great

Thank for providing link [:)}

UpdatePanel / Gridview / ButtonField - Strange Behaviour

Hi everyone,

I have a strange problem that I've managed to narrow down to being an issue with the UpdatePanel control. Hopefully someone could advise me...

I have an UpdatePanel which contains a Gridview which isnot bound to a dataset etc. I populate the gridview manually by constructing my own table, defining grid columns then binding it to my table etc. Several of the columns in the gridview are of typeButtonField withButtonType set to "Button"

Now, all of this is working fine...no problems whatsoever.

I decided later that rather than a button I wanted a link instead, so where I construct the GridView's columns using a ButtonField column type, I simply changed
"MyCol.ButtonType = ButtonType.Button" to "MyCol.ButtonType = ButtonType.Link"

My problem is that by making this simple change, the page now does not work. The page still renders exactly as expected, but when I click on one of the link buttons, none of the events are fired...instead, I get the icon at the bottom left of explorer indicating an error on the page. When I look at the error all I get is:

Line: 1
Char: 1
Error: Object expected
Code: 0
URL: xxxxxxxxxx

Remember, the only change I made was to change the ButtonType, nothing else.

This issue seems to be related to the UpdatePanel as when I remove the Ajax controls from the page, it performs exactly as expected...that is, my code to catch the MyGrid_RowCommand event fires whether the ButtonType is Button or Link. When I put the UpdatePanel back, the page only works when ByttonType is set to Button, but not for Link.

Please note that I do not want a HyperLink field. I want a ButtonField so that I can catch the click events and process them. My Code that I'm using for testing this is below.

Thanks in advance,

MJ

To test this, try the code as-is below to replicate the error. Change the "Code-Behind" and set the ButtonType to Button and it will work. For the third test, remove the Ajax controls from the Web Page and the code will work with ButtonType set to Button or Link

HTML PAGE

<%@dotnet.itags.org. Page Language="VB" AutoEventWireup="true" CodeFile="HomePage.aspx.vb" Inherits="_HomePage" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Testing</title>
</head>
<body>
<form id="form1" runat="server">
<atlas:ScriptManager ID="ScriptManager1" runat="server" EnablePartialRendering="True">
</atlas:ScriptManager>
<atlas:UpdatePanel ID="UpdatePanel1" runat="server" EnableViewState="true" >
<ContentTemplate>
<asp:Button ID="Button1" runat="server" Text="Button" />
<asp:GridView ID="MyGrid" runat="server" />
<asp:Label ID="lblResults" runat="server" />
</ContentTemplate>
</atlas:UpdatePanel>
</form>
</body>
</html>

CODE BEHIND


Partial Class _HomePage
Inherits System.Web.UI.Page

Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click

MyGrid.DataBind()

End Sub
Protected Sub MyGrid_DataBinding(ByVal sender As Object, ByVal e As System.EventArgs) Handles MyGrid.DataBinding

Dim MyRowPtr As Integer
Dim MyTable As New Data.DataTable

'Initialise Grid properties
With MyGrid
.AutoGenerateColumns = False
.BorderWidth = 1
.CellPadding = 0
.CellSpacing = 0
.Columns.Clear()
.EnableViewState = True
End With

'Create Table Columns
'Create Grid Columns
For MyRowPtr = 1 To 3
Dim lTableCol As New Data.DataColumn
lTableCol.ColumnName = Chr(MyRowPtr + 64)
MyTable.Columns.Add(lTableCol)

Dim lGridCol As New ButtonField
With lGridCol
.ButtonType = ButtonType.Link ' <======= CHANGE THIS LINE HERE
.ControlStyle.BorderWidth = 0
.ControlStyle.BorderStyle = BorderStyle.NotSet
.ControlStyle.BackColor = Drawing.Color.Azure
.CausesValidation = True
.HeaderText = Chr(MyRowPtr + 64)
.DataTextField = lTableCol.ColumnName
.CommandName = MyRowPtr.ToString
End With

MyGrid.Columns.Add(lGridCol)

Next

'Create 2 rows in the data table
Dim MyRow As Data.DataRow

MyRow = MyTable.NewRow
MyRow.BeginEdit()
MyRow("A") = "Row0 Col1"
MyRow("B") = "Row0 Col2"
MyRow("C") = "Row0 Col3"
MyRow.EndEdit()
MyTable.Rows.Add(MyRow)

MyRow = MyTable.NewRow
MyRow.BeginEdit()
MyRow("A") = "Row1 Col1"
MyRow("B") = "Row1 Col2"
MyRow("C") = "Row1 Col3"
MyRow.EndEdit()
MyTable.Rows.Add(MyRow)

MyTable.AcceptChanges()

MyGrid.DataSource = MyTable
MyGrid.Visible = True

End Sub

Protected Sub MyGrid_RowCommand(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewCommandEventArgs) Handles MyGrid.RowCommand

Dim SelectedRow As Integer
Dim SelectedColumn As Integer

'Re-bind the grid...required to save the formatting of the buttons
MyGrid.DataBind()

SelectedRow = Convert.ToInt32(e.CommandArgument)
SelectedColumn = Convert.ToInt32(e.CommandName)

Me.lblResults.Text = "You selected Column " & SelectedColumn.ToString & ", Row " & SelectedRow.ToString

End Sub
End Class

Check out this thread, see if the posted solution helps:

http://forums.asp.net/thread/1257072.aspx


Curious why do you create GridView columns programatically? You can define the columns in the aspx and still have dynamic table built on the server. I have GridView with linkbuttrons and it works fine. I wonder what happens if you declare ButtonField this way..


Matt M:

Check out this thread, see if the posted solution helps:
http://forums.asp.net/thread/1257072.aspx

Matt,

Thanks for the link. I read through it and found 3 "potential" scenario's I could try that might be a fix for my problem. I tried all 3 and I'm happy to say that one (but only one) worked.

The solution that worked for me was placing this code in my page_load event:
Page.ClientScript.GetPostBackEventReference(me, String.Empty)

It seems that this is a known bug, and according to the post, was supposed to have been fixed in prior releases (I'm on the July release). Is there somewhere where I can log this as a bug, or that it's still a bug?

Anyway, I'm all go again...thank you so much for responding to my original post, I appreciate it.

MJ


StanB:

Curious why do you create GridView columns programatically? You can define the columns in the aspx and still have dynamic table built on the server. I have GridView with linkbuttrons and it works fine. I wonder what happens if you declare ButtonField this way..

I Stan,

Yes, you're right, I could have done it the way you have suggested. The problem in my case is that the number (and type) of columns will change regularly depending on user interaction, so this is why I can't set them up at design time.

MJ

Wednesday, March 21, 2012

UpdatePanel and GridView

I have a GridView that updates a FormView, ive now added the UpdatePanel around the FormView.

When I select a row from the Gridview the FormView Displays the details inside the FormView..great, but......

I have paging enabled on the Gridview so when I click page 2 i dont see the new list in the GridView, how do I fix this?

<-- GridView1 -->

<

MsAjax:ScriptManagerid="ScriptManager"runat="server"EnablePartialRendering="true"/><MsAjax:UpdatePanelID="ID1"runat="server"><ContentTemplate>

<--FORMVIEW -->

</

ContentTemplate>

<Triggers>

<MsAjax:AsyncPostBackTriggerControlID="GridView1"EventName="RowCommand"/>

</Triggers></MsAjax:UpdatePanel>

Hi

Putting UpdatePanel around formview should not effect GridView's Paging. If you have paging enabled it should display you the next records in the table. Does it actually select the page No. 2. or it stays on 1.

Amit


If you want to see the updated list (from the FormView), you must put the GridView also in a UpdatePanel.
Can be in the same UpdatePanel where the FormView is in, or in a new UpdatePanel.
If he's in a other Updatepanel, be sure to attach a trigger to the FormView to it.

(i'm not sure if this is what youre problem was, but you never know..)

UpdatePanel and Popup

Hi All,

I've a page containing a form divided into 4 steps:

<UpdatePanel>

<Multiview>

<View1>GridView showing students' information

<View2>Form for Add/Edit student's personal info

<View3>form for add/edit student's home info

<View4>form for add/edit student's parents info

</Multiview>

</UpdatePanel>

Every view have a next button to change the active view to the next view and in view4 these is a save button to save the data into database then change the active view to view 1.

In view 2 there is a button popup a window of student's semester subjects list for user to enter their score. My problem is, after I press save button in the popup to save the subject score the parent window autometically refresh and active view change back to View1... How can I make the parent window not refresh when I save the info of popup window?

Thanks,

Tim

What are you using for a popup? You can try using the ModalPopuphttp://www.asp.net/AJAX/Control-Toolkit/Live/ModalPopup/ModalPopup.aspx.

-Damien


Hi Damien,

Because I need to use the FileUploadControl to upload student's project files/exam paper ... this requires a full post back so cannot work inside updatepanel..

Cheers,

Tim


The ModalPopup doesn't require an UpdatePanel.

-Damien