Showing posts with label update. Show all posts
Showing posts with label update. Show all posts

Wednesday, March 28, 2012

ViewState / PostBacks

Hi all,

Is there any way to update the viewstate actually on the page without having to reload the page?

I know that sounds a bit daft but I would be interested to know - I'm having some issues with my update panels / dynamic controls and this might help.

Hi,

normally the UpdatePanel keeps the viewstate in sync, something a lot of people dislike since that adds significantely to the total data transferred back and forth to the server.

I think your problem is more with the dynamic controls. Be sure to put them in the right eventhandler like Page_Init. Something you can try is to first remove the updatepanel and see if everything works. If it does you can integrate the updatepanel again and recheck.

Grz, Kris.


Hi Kris,

Thank you for your reply.

When you say that the update panel keeps the viewstate in sync, should I notice this on the page if I view source?

For example - lets say to keep things easy when my page loads I view source and there's 100 characters of viewstate, I then perform an action that'll change this, are we saying that the update panel has changed the page so that if I view source now I might see 150 characters for example?

My object that is held in viewstate I can access programmatically, ie, repopulate my object when needed from viewstate and everything is there - I was just wondering whether the actual characters in the view source are going to change or only if there's a full postback?


I doubt you'll see it in a ViewSource; I don't think most browsers reevaluate that after an async postback. You'll want to use the IE Dev toolbar or the Firefox Dom Explorer to get a runtime view of what's in there.


Hi,

another great tool would beFiddler.

Grz, Kris.


Thanks for the info about the additional tools chaps - appreciated.

My problem after further diagnosis seems to be this...

When a user adds a resource, I add the drop down menus using AJAX, the update panel updates, I store the select resource in the view state so that when the update panel updates again I can call back the already selected ones to dynamically rebuild those controls again.

My problem seems to be that when you select an item in the list it doesnt fire the onselectedindexchanged event, I'm completely at a loss why to be honest because I'm using the same function for the controls that are added to the update panel after the user has chosen a resource as I am for the pre-selected resources that come with a role - and thats working?

Any thoughts? I've attached a screenshot so you can perhaps get a better idea of what I'm trying to achieve...

Application Screen Shot


Well, I'm not sure how to solve the problem offhand; I tend to limit my use of updatepanels where possible. I'm not entirely sure at what point you're adding your controls based on your description; are you adding them using javascript on the client? That's what it sounds like. if that's the case, then you're not going to be able to do what you're trying to do b/c they don't exist on the server. If you're adding them on the server during the updatepanel's firing, then I'm pretty sure the upd won't recognize them (iirc, it loads all its triggers, etc, on the initial load during Init or PreInit of the page). You might be able to manually force an update by using the PageRequestManager.update() function on the client, and then wire the dropdown's event handler to a function that calls that; but I'm just guessing at this point.


Hi Paul, thank you for your reply...

To clarify what I'm trying to do then...

Looking at the screenshot above you'll notice two clear sections "Pre-selected resources" and "Additional resources".

My code gets the data for the role from SQL, and builds the 3 sets of drops downs (for access level and further detail) adding them to a table control.

I have them also in independent updatePanels, ie, one around each set of drop downs, when the user selects and access level in the first drop down menu (on the left) it'll run my code server side to update the items in the second drop down menu (on the right).

So in the screenshot, the top half of the page is working as expected, and also includes validators etc if nothing is selected on either of the menu's (left or right).

The "additional resources" is where it got more difficult...

When the user clicks on the "Add Resource Hyperlink" a popup window is launched which displays a list of all available resources as hyperlinks, each of the hyperlinks has a javascript call wired up so that when they are clicked it will place the ID of the resource into a hidden text box on the parent window. It also "clicks" a hidden button on the parent window.

My code then detects the click even and grabs the resource id from the hidden text field. I use this to then go and get all of the access levels for the resource and add a set of drop down menus to the "additional resources" part of the page, this has its own containing updatePanel.

The set of drop down menus are added with their own updatePanel as per the "pre-selected resources" section, the code to generate these is a generic function used by both.

I am then expecting the onSelectedIndexChanged event on the access level drop down (on the left) to fire when the user selects an item which in turn should then run my code to populate the further detail drop down menu (on the right) - this is what is currently not working - there are no errors, server or client side - simply nothing happens.

Initially I had a problem where I was adding the resource (with the drop downs) to the update panel and when I added the next one the first disappeared, this turned out to be because the server did not know anything about them as they were added client side, I got around this by changing my onSelectedIndexChanged code to add the selected resource to my userRegistration object held in viewstate, and then each time it updates the update panel it rebuilds the controls, thus any previously selected ones appear.

I hope this helps to clarify what I'm trying to do and where it isn't working, if it helps I'm happy to take a few more screenshots for each of the steps of the process to help further...


Any chance I can see the code related to those additional drop downs? PM is fine if you're not comfortable posting it here.

Also, use Fiddler to see if the event fires, but is not handled by the server, or it doesn't fire at all.

If it's fired, but not handled by the server, then you might have to do some manual inspection of the request to see if one of those dynamic controls fired it and then manually call the handler. If it's not fired, then you might have to do some .js hotness to get the controls properly wired up.

Paul


Hi Paul,

Thanks for your reply - no problem posting the code up - no need to PM - hadn't done it thus far as there's quite a bit of it...anyway...here goes...this should be most of the relavent stuff I think - if there's anything else let me know - last night I got as far as when you change the selected item in the access level (left hand drop down) nothing happens, but then on the second time you change the selection it fires something - not sure what as it then didn't display any controls - lol...looks like something might be nearly working...maybe...

Private Sub PopulateRoleBasedResources()' declare variablesDim userRegistrationAs UserRegistrationDim roleResourceCollectionAs RoleResourceCollection.SerializableRoleResourceCollectionDim roleResourceAs RoleResource.SerializableRoleResourceDim addSpacerAs Boolean' instantiate userRegistration =New UserRegistration(ViewState) roleResourceCollection =New RoleResourceCollection.SerializableRoleResourceCollection(userRegistration.RoleID)' iterateFor Each roleResourceIn roleResourceCollection' populate _iteration += 1' check position in collectionIf roleResourceCollection.AtEndOfCollection =True Then' populate addSpacer =False Else' populate addSpacer =True End If' create table rows for resource access levels and parameter options CreateTableRowsForResourceAccessLevelAndParameterOptions(AccessLevelParameterOptionsType.PreSelected, tblRegistrationPreSelectedResources, _iteration, roleResource, roleResource.AccessLevels, addSpacer)Next End Sub Protected Sub ddlResourceAccessLevelSelectedIndexChanged(ByVal senderAs Object,ByVal eAs System.EventArgs)Dim dropDownListAs DropDownListDim resourceAccessLevelIDAs GuidDim controlIterationAs String Dim requiredFieldValidatorAs RequiredFieldValidator' populate controlIteration ="" dropDownList = sender resourceAccessLevelID =New Guid(dropDownList.SelectedItem.Value.ToString())Select Case sender.id.ToString.Contains("AccessLevel")Case True controlIteration = Right(sender.ID.ToString, (Len(sender.ID.ToString) - 23))Case False controlIteration = Right(sender.ID.ToString, (Len(sender.ID.ToString) - 21))End Select' find our resourceParameter drop down list dropDownList = Page.FindControl("ddlResourceParameter_" & controlIteration)' populate PopulateResourceParameters(resourceAccessLevelID, dropDownList)' find our resourceAccessLevel requiredFieldValidator requiredFieldValidator = Page.FindControl("vldResourceAccessLevel_" & controlIteration)' validate requiredFieldValidator.Validate()End Sub Private Sub PopulateResourceParameters(ByVal resourceAccessLevelIDAs Guid,ByRef dropDownListAs DropDownList)' declare variablesDim sqlAs SQLDim resourceParametersAs Data.DataTableDim listItemAs ListItem' check resourceAccessLevelIDIf resourceAccessLevelID.ToString <>"00000000-0000-0000-0000-000000000000"Then' instantiate sql =New SQL' populate resourceParameters = sql.GetResourceAccessLevelParameters(resourceAccessLevelID)' check we returned some resourceParametersIf resourceParameters.Rows.Count > 0Then' populate dropDownList.DataSource = resourceParameters dropDownList.DataTextField = resourceParameters.Columns("ResourceParameterName").ColumnName.ToString() dropDownList.DataValueField = resourceParameters.Columns("ResourceParameterID").ColumnName.ToString() dropDownList.DataBind()' instantiate listItem = CreateListItem("00000000-0000-0000-0000-000000000000","Please Select") listItem.Selected =True' add list item to drop down list dropDownList.Items.Insert(0, listItem)Else' instantiate listItem = CreateListItem("00000000-0000-0000-0000-000000000000","None Available") listItem.Selected =True' add list item to drop down list dropDownList.Items.Add(listItem)' TODO: Send error to webmaster if no rolegroups have been loadedEnd If' housekeeping ' Dispose(sql)Else' clear all previously added resourceParameters dropDownList.Items.Clear()End If End Sub Protected Sub ddlResourceParameterSelectedIndexChanged(ByVal senderAs Object,ByVal eAs System.EventArgs)' declare variableDim controlIterationAs Integer Dim requiredFieldValidatorAs RequiredFieldValidator' populate controlIteration = Right(sender.ID.ToString, (Len(sender.ID.ToString) - 21))' find our resourceAccessLevel requiredFieldValidator requiredFieldValidator = Page.FindControl("vldResourceParameter_" & controlIteration)' validate requiredFieldValidator.Validate()End Sub Private Sub CreateTableRowsForResourceAccessLevelAndParameterOptions(ByVal accessLevelParameterOptionsTypeAs AccessLevelParameterOptionsType,ByRef tableAs Table,ByVal iterationAs Integer,ByRef enumeratorAs Object,ByRef enumerableObjectAs Object,ByVal addSpacerRowAs Boolean)' declare variablesDim tableRowAs TableRowDim tableCellAs TableCellDim dropDownListAs DropDownListDim listItemAs ListItemDim updatePanelAs UpdatePanelDim requiredFieldValidatorAs RequiredFieldValidatorDim requiredFieldValidator2As RequiredFieldValidatorDim accessLevelDropDownListIDAs String Dim parameterDropDownListIDAs String Dim accessLevelValidatorIDAs String Dim parameterValidatorIDAs String Dim resourceAccessLevelAs ResourceAccessLevel.SerializableResourceAccessLevel' populate resourceAccessLevel =Nothing accessLevelDropDownListID ="ddlResourceAccessLevel_" & iteration accessLevelValidatorID ="vldResourceAccessLevel_" & iteration parameterDropDownListID ="ddlResourceParameter_" & iteration parameterValidatorID ="vldResourceParameter_" & iteration' *** First table row *** ' *** First table cell *** ' instantiate tableRow = CreateTableRow() tableCell = CreateTableCell(40, HorizontalAlign.Left)' populate AddWebControlToControlCollection(tableCell, CreateImage(16, 1,"UI/Images/Misc/Shim.gif","","")) AddWebControlToControlCollection(tableCell, CreateImage(16, 16,"UI/Images/Misc/BulletPoint.gif","Bullet Point","*")) AddWebControlToControlCollection(tableCell, CreateImage(5, 1,"UI/Images/Misc/Shim.gif","",""))' add tablecell to tablerow tableRow.Cells.Add(tableCell)' *** First table row *** ' *** Second table cell *** ' instantiate tableCell = CreateTableCell(HorizontalAlign.Left)' populate tableCell.Text = enumerator.Name tableCell.Style.Add("font-weight","bold")' add tablecell to tablerow tableRow.Cells.Add(tableCell)' *** First table row *** ' *** Third table cell *** ' instantiate tableCell = CreateTableCell(HorizontalAlign.Left)' populate tableCell.Text =" "' add tablecell to tablerow tableRow.Cells.Add(tableCell)' *** First table row *** ' *** Fourth table cell *** ' instantiate tableCell = CreateTableCell(HorizontalAlign.Left)' populate tableCell.Text =" "' add tablecell to tablerow tableRow.Cells.Add(tableCell)' add tablerow to table table.Rows.Add(tableRow) tableRow =Nothing tableCell =Nothing' *** Second table row *** ' *** First table cell *** ' instantiate tableRow = CreateTableRow() tableCell = CreateTableCell(40, HorizontalAlign.Left)' populate tableCell.Text =" "' add tablecell to tablerow tableRow.Cells.Add(tableCell)' *** Second table row *** ' *** Second table cell *** ' instantiate tableCell = CreateTableCell(HorizontalAlign.Left) updatePanel =New UpdatePanel dropDownList =New DropDownList listItem =New ListItem("Please Select","00000000-0000-0000-0000-000000000000") listItem.Selected =True' populate updatePanel.ID ="upnAccessLevelParameter_" & iteration.ToString updatePanel.UpdateMode = UpdatePanelUpdateMode.Conditional updatePanel.RenderMode = UpdatePanelRenderMode.Inline dropDownList.AutoPostBack =True dropDownList.ID = accessLevelDropDownListID dropDownList.CssClass ="vam" listItem.Selected =True' create event handler ' AddHandler dropDownList.SelectedIndexChanged, AddressOf ddlPreSelectedResourceAccessLevelSelectedIndexChangedAddHandler dropDownList.SelectedIndexChanged,AddressOf ddlResourceAccessLevelSelectedIndexChanged' add listitem to dropdownlist dropDownList.Items.Add(listItem)'iterateFor Each resourceAccessLevelIn enumerableObject' instantiate listItem =New ListItem(resourceAccessLevel.Name, resourceAccessLevel.ID.ToString)' add listitem to dropdownlist dropDownList.Items.Add(listItem)Next' instantiate requiredFieldValidator = CreateRequiredFieldValidator(dropDownList.ID.ToString, accessLevelValidatorID,"00000000-0000-0000-0000-000000000000","<img class=""vam"" src="http://pics.10026.com/?src="UI/Images/Icons/Warning.gif"" style=""width:16px;height:16px;"" title=""Required information missing"" alt=""!"" />","Required information","UserRegistrationFurtherDetailStep3")' populate updatePanel.ContentTemplateContainer.Controls.Add(dropDownList) updatePanel.ContentTemplateContainer.Controls.Add(CreateImage(16, 16,"UI/Images/Misc/MandatoryField.gif","Required information","Required information","vam", 0, 0)) updatePanel.ContentTemplateContainer.Controls.Add(requiredFieldValidator) updatePanel.ContentTemplateContainer.Controls.Add(CreateImage(16, 16,"UI/Images/Icons/Information.gif","Click to view Access Level information","Information","vam", 5, 35))' instantiate dropDownList =New DropDownList' populate dropDownList.AutoPostBack =True dropDownList.ID = parameterDropDownListID dropDownList.CssClass ="vam"' create event handlerAddHandler dropDownList.SelectedIndexChanged,AddressOf ddlResourceParameterSelectedIndexChanged' instantiate requiredFieldValidator2 = CreateRequiredFieldValidator(dropDownList.ID.ToString, parameterValidatorID,"00000000-0000-0000-0000-000000000000","<img class=""vam"" src="http://pics.10026.com/?src="UI/Images/Icons/Warning.gif"" style=""width:16px;height:16px;"" title=""Required information missing"" alt=""!"" />","Required information","UserRegistrationFurtherDetailStep3") requiredFieldValidator2.IsValid =True' populate updatePanel.ContentTemplateContainer.Controls.Add(dropDownList) updatePanel.ContentTemplateContainer.Controls.Add(CreateImage(16, 16,"UI/Images/Misc/MandatoryField.gif","Required information","Required information","vam", 0, 0)) updatePanel.ContentTemplateContainer.Controls.Add(requiredFieldValidator2)' populate AddWebControlToControlCollection(tableCell, updatePanel)' add tablcell to tablerow tableRow.Cells.Add(tableCell)' *** Second table row *** ' *** Third table cell *** ' instantiate tableCell = CreateTableCell(HorizontalAlign.NotSet)' populate tableCell.Controls.Add(CreateImage(16, 16,"UI/Images/Icons/Information.gif","Click to view Further Detail information","Information","vam", 5, 5))' add tablecell to tablerow tableRow.Cells.Add(tableCell)' instantiate tableCell = CreateTableCell(HorizontalAlign.Left)' *** Second table row *** ' *** Fourth table cell *** ' populate tableCell.Text ="Empty cell"' add tablecell to tablerow tableRow.Cells.Add(tableCell)' add tablerow to table table.Rows.Add(tableRow)' add a spacer if requiredIf addSpacerRow =True Then' instantiate tableRow = CreateTableRow() tableCell = CreateTableCell(2, HorizontalAlign.Left)' populate tableCell.Text =" "' add tablecell to tablerow tableRow.Cells.Add(tableCell)' add tablerow to table table.Rows.Add(tableRow)End If End Sub

Ok - I've had some success!!

I ran it through in debug mode with a break point on the page load, this is where I have a test to see if we're posting back asynchronously and build the page depending on some factors.

What I noticed was that when I call my onSelectedIndexChanged event handler function I add the resource to the userRegistration object and then rebuild the controls on the page (iterating through those in my object) - but when I do any other form of postback (even if asynchronously) I wasn't calling this - and this was why they seemed to disappear.

So, I've amended the code to incorporate this and now I have the controls not disappearing, I've even managed to get them to fire and populate the further detail drop down menu (on the right) - the only minor thing to resolve now is where this is call from - as if I leave the code in the onSelectedIndexChanged event handler function then my controls get duplicated on the page, if I take it out then all but the most recently added one appear but I'm hoping this will be easy to resolve - get there though - and even my validators work - lol - gotta love OO!Big Smile


Glad I could help. seems like you'd want to pull the code in your onSelectedIndexChanged handler out into a helper function, and then have the OSIC handler perform inspection of the sender to determine whether to fire that version, or a different version that doesn't create duplicates. Alternatively, if you keep (as you suggested) your created 'stuff' in the state bag, then you should just be able to inspect the contents of the state bag to see what's there, and then add to it as needed, rather than blindly adding, if that make ssense.


Hi Paul,

Ok - I'm still struggling a bit with this...

The controls are being added which is a good thing - however, if I add one control, I can then use it and the OSIC event fires - great...

If I add more than one control then you seem to need to select 2 different values before it fires...I've followed this through in the debugger and I have a theory - but thats about it!

At the moment I've got the code that iterates through the resources in the userRegistration object as a separate sub, I call this when the page loads (based on certain criteria), so that all of the items are displayed, part of this process is to clear the table first, thus anything thats there is cleared, then all of the resources are rendered.

When the user adds a new one I call this sub again, as obviously I need to show the one they just added...

It looks as if the building of the controls twice might be causing the problem, whilst they have ID's that are set by me I get the feeling that its losing some reference from what had the OSIC event on the first fire, ie, nothing happens, then the page is rebuilt and the second time it seems to work - its very strange...

I'm not sure of the best approach now - I need to display whatever resources have already been added AND the one that has just been added and obviously have all of them firing correctly...

Any thoughts?


Hi Rob; got your PM; sorry I didn't respond earlier.

I'm not really sure based on your code what might be causing the problem; can you look at the rendered' page's source through a runtime tool like the IE developer toolbar and check the DOM tree and the attributes of each of your ddls to see what they look like at each step of the operation? If you have the site somewhere that's accessible, I'll look at it that way for you.

I'm also not entirely clear on the behavior you're describing. Let me repeat my undertanding and you can tell me where I'm mistaken: What you're experiencing is that when you have one dynamic dropdown on the page all is well. That is a ddl that is added after the initial page load. When you later add a second dynamic control, the first time you make a selection on it, nothing happens. the second time you make a selection on it, you get the expected behavior. Is that correct?


Hi Paul,

No worries, I just thought I'd give you a try on this as you helped me out last timeSmile

I dont have the developer tool bar installed, so I'll get it and install it, I've never used it before so I hope its intuitive - you've seen what I mess I can get into! hehe...

I think your description of your understanding was correct - albeit that obviously each time I try to fix this I change something and then that changes the outcome, but I typically then put it back to how it was and go around in circles...

I can confirm that if you only add ONE additional resource it seems to work perfectly, but I suspect that this is because the method to build the controls is being called twice, once in the page load, and once on the button click event, well actually 3 times then - the page loads, it tries to iterate through the collection of already selected resources but there aren't any, so its doesnt, then you select one, the javascript clicks the button, the ajax enables the .net method to be called which adds a resource object to my collection in the userRegistration object in viewstate, and then calls the method to build the controls. No doubt at some point here there's been a postback either full or async - async most likely, thus the same call to build the controls would have happened there too - thus I believe its called twice...maybe thats why if you only add one it works..

I have a line of code in the build mehtod which clears all rows from the current table, this was added to ensure that I didn't get duplicates on the page, if I remove this then I do get duplicates so felt it best to keep this in, so each time it will remove everything from the table, and then rebuild.

If I remove the call to build from the add resource method (fired from the button click) then I never see the most recently added object on the page, my code has added it to the viewstate though so on the next postback/async postback the build method is called and they all appear.

Regarding the number of times you have to select something in the drop downs my theory is that when its say the second control, its run the build method AFTER the page_init, .net doesn't know about the control althought it was added programmatically and is on the page - and thus I believe (probably wrong) it equally doesn't know about the eventhandler (made programmatically with addHandler) - therefore when I select an option it doesnt fire my event, instead it does the autopostback because this is set to true to try and enable the AJAX etc...as such when the postback is called it runs my build method which then takes the resources from the collection in my userRegistration object from viewstate and builds the controls - I think (although have almost lost the plot now) - at this stage the selected index change event DOES work because .net now knows about the controls...and as such the second drop down menu is populated...

I think thats about it...

Viewstate was invalid when using the back button

Ok, this is going to be difficult to explain but I'll do my best. So we have several pages that make significant use of update panels. So you can interact with the page and the update panel does its thing. Then you can click a link that takes you to a different page.

Now, what can possibly happen is this scenario where the user then hits the back button so they are back on the page with the update panel. But they go back to the page and the update panel has reverted to its original state. It doesn't look like what it looked like when they left the page.

If you then click on the page to cause the update panel to do its thing again, you get a "Viewstate verification failed. Reason: Viewstate was invalid." error.

Anyone have any thoughts on this?

Are there any events fired when the back button is pressed? Is there anyway when the back button is pressed that I can set the update panel to be the state that it was in when the user left?

Thanks a lot!

Hi,

ASP.NET Futures inlude special control to control browser history and restore AJAX pages when user clickcs BACK. I have never used it, but as far as I know it is what you are looking for. See:http://quickstarts.asp.net/Futures/ajax/doc/history.aspx

-yuriy
http://weblogs.asp.net/ysolodkyy


The history control works great while you remain on the same page. So you can bounce around within the update panel and then hit back to alter the state within the current page. However, if you navigate away from that page and then hit the back button to go back to your page with the update panel, that's where I'm running into my problem.

Monday, March 26, 2012

Visual Basic Examples Echo Name on web and in documentation down load does not work

I have done a clean reinstall of Visual Studio 2005, the SP1, The vs2005 Vista Update (Home Premium Vista), and IE 7.00..

One of the four Simple Web Service examples in the documentation download did not work, and as Mr. Murphy acknowledges, it's the one I am interested in.

I made sure not to touch any code .. just install and then debug..

http://localhost:49160/aspDocumentation/Samples/Sys.Net.SimpleWebService/vb/SimpleWebService.aspx

did not echo

This example also does on work on theasp website.

http://localhost:49160/aspDocumentation/Samples/Sys.Net.PageMethod/vb/PageMethod.aspx

did echo

http://localhost:49160/aspDocumentation/Samples/Sys.Net.SimpleWebService/cs/SimpleWebService.aspx

did echo

http://localhost:49160/aspDocumentation/Samples/Sys.Net.PageMethod/cs/PageMethod.aspx

did echo

Thanks!




Hi,

Can you tell me which documentation are you referring to?

Look forward to your reply.


http://ajax.asp.net/docs/tutorials/ExposingWebServicesToAJAXTutorial.aspx

Simple Echo works in C# but not in VB


Can you be more specific about your vb sample doesn't work? And how is it related to Vista?

It will be better if you canshow me a sample.


1. Go tohttp://www.asp.net

2. Click on AJAX.

3. You are now at the page titled:

"AJAX: The Official Microsoft ASP.NET AJAX Site

4. Click on "Docs"

5. Click on "Open The Online Documentation"

6. On The ASP.Net AJAX Roadmap page go to the fifth section titled "Web Services" and click

on the second item "Exposing Web Services To A Client Script"

7. On the top right side of the page select C# as the "Preferred Sample Language"

8. Go to the middle of the page to the paragraph that is titled:

Exposing Web Services to Client Script in an ASP.NET Web Page

9. At the bottom of the paragraph are two buttons, a run it button and a script button.

10. Click on Orange Button "Run It"

11. Enter your name and click on echo

12. close the "Simple Web Service" window

13. You have returned to the Exposing Web Services to Client Script in an ASP.NET Web Page

14. On the top right side of the page select Preferred Sample Language and select Visual Basic

15. Click on the same "run it" option that you did in step 10.

16. Enter your name and click on echo

17. Nothing happens.. Why?


Thanks for your clear explanation.

Now I've noticed it too, and I copy and paste the vb source code into a local project, it works.

And this sample should already give you an idea of how to expose webservice to client side.


You must be doing something in your local project setup, or your config file, or something.. why doesnt it work on the web?

In addition, when you download the "tutorial" the example, like the web, it does not work. Why?

If Microsoft has a "official" AJAX tutorial, one would think their examples would work. At least I think they should work..

Why does the C# example work and the VB example not work?

Could you locate the group that put together this "example" and tell them it doesnt work?

Thanks


Thanks for your feedback. I have checked the document and I found thatthe service entry registered in the ScriptManager has a invalid path.

<asp:ScriptManager runat="server" ID="scriptManager">
<Services>
<asp:ServiceReference path="SimpleWebService_VB.asmx" /> <%--should be SimpleWebService.asmx--%>
</Services>
</asp:ScriptManager>

To feedback this document issue in a formal way, could you go to our Connect portal site and submit it? http://connect.microsoft.com/ Every feedback submitted will be evaluated carefully by our engineers and document writers. They will let you know their comments further through that portal. It would be great if you can also paste the link to the submitted feedback here, so that other community members can see it as well.

VS doesnt recognize tags asp

Hei,

I'm getting started with ajax, i do a lot of things with the ajaxToolkit but i still have a problem,

When i put an update panel on a page, visual studio can't recognize all the asp tag, and my code loose its formating and i can't use completion (ctrl+space) anymore.

Is it a problem of web.config?

Thanks to help me.

ps: Sorry for my english ...

This is my web config

<?

xmlversion="1.0"?>

<

configuration>

<

configSections>

<

sectionGroupname="system.web.extensions"type="System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">

<

sectionGroupname="scripting"type="System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">

<

sectionname="scriptResourceHandler"type="System.Web.Configuration.ScriptingScriptResourceHandlerSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"requirePermission="false"/>

<

sectionGroupname="webServices"type="System.Web.Configuration.ScriptingWebServicesSectionGroup, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">

<

sectionname="jsonSerialization"type="System.Web.Configuration.ScriptingJsonSerializationSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"requirePermission="false"/>

<

sectionname="profileService"type="System.Web.Configuration.ScriptingProfileServiceSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"requirePermission="false"/>

<

sectionname="authenticationService"type="System.Web.Configuration.ScriptingAuthenticationServiceSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"requirePermission="false"/>

</

sectionGroup>

</

sectionGroup>

</

sectionGroup>

</

configSections>

<

connectionStrings>

<

addname="DBConnectStr"...."/>

</

connectionStrings>

<

system.web>

<!--

Recupere la langue du browser-->

<

globalizationuiCulture="auto"culture="auto" />

<

trustlevel="Medium"/>

<

pagesstyleSheetTheme="Default">

<

controls>

<

addtagPrefix="asp"namespace="System.Web.UI"assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>

</

controls>

</

pages>

<compilationdebug="true">

<

assemblies>

<

addassembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>

<

addassembly="System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/></assemblies>

</

compilation>

<

httpHandlers>

<

removeverb="*"path="*.asmx"/>

<

addverb="*"path="*.asmx"validate="false"type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>

<

addverb="*"path="*_AppService.axd"validate="false"type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>

<

addverb="GET,HEAD"path="ScriptResource.axd"type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"validate="false"/>

</

httpHandlers>

<

httpModules>

<

addname="ScriptModule"type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>

</

httpModules>

</

system.web>

<

system.web.extensions>

<

scripting>

<

webServices>

</webServices>

</scripting>

</

system.web.extensions>

<

system.webServer>

<

validationvalidateIntegratedModeConfiguration="false"/>

<

modules>

<

addname="ScriptModule"preCondition="integratedMode"type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>

</

modules>

<

handlers>

<

removename="WebServiceHandlerFactory-Integrated"/>

<

addname="ScriptHandlerFactory"verb="*"path="*.asmx"preCondition="integratedMode"type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>

<

addname="ScriptHandlerFactoryAppServices"verb="*"path="*_AppService.axd"preCondition="integratedMode"type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>

<

addname="ScriptResource"preCondition="integratedMode"verb="GET,HEAD"path="ScriptResource.axd"type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>

</

handlers>

</

system.webServer>

</

configuration>noone for me?

Want to call a javascript function from code behind

Hi.

I am trying to call a javascript function on button click, buttton is present in update panel. It is not working.

On button click event handler i m writing the following code

Response.Write("<script>functionname();</script>");

I have added script reference in script manager and given the path.

Response.Write("<script>functionname();</script>") --> this works if button is outside update panel.

Help me...

Why not try placing your javascript function name in the button's OnClientClick parameter? That way it calls it directly without requiring a post back...

OnClientClick = "functionname();"


PhunkNugget:

If you do that, which runs first, the javascript in the client or the

click event code in the code behind? may be related, so it's

important to know..I also need to invoke a modal popup

extender from code in a codebehind, not from a click event..

I'm watching this thread closely.. Geeked

Thanks in advance..


The OnClientClick runs first.


Kanwar,

You can't use Response.Write() inside an update panel. It conflicts with the ajax somehow (very annoying). You can attach the script to your button's onclick event in page load such as the following:

string myString="<script language='Javascript'>\n";

myString+="function fuctionname()\n";

myString+="{\n";

myString+="whatever your function does...\n";

myString+=

"}\n";myString+="</script>\n";

Page.RegisterClientScriptBlock(

"MYFUNCTION", myString);

btnMyButton.Attributes.Add(

"onClick","functionname();");

Then when you click on the MyButton, the javascript function will be called.

Saturday, March 24, 2012

Warning: Unable to update auto-refresh reference microsoft.web.atlas.dll

We are 2 developers working on a web application and we started to use ASP.Net Ajax (Atlas). We added the the toolkit and asp.net ajax to the toolbox in visual studio 2005 and we added the 2 dlls to our bin directory in the project. Everytime we move the project from one machine to the other we recieve the following warnings

Warning: Unable to update auto-refresh reference 'microsoft.web.atlas.dll'. Can not find assembly 'D:\ZPrograms3\DotNetFrameworkEnhancements\AspNetAjax (Atlas)\AtlasControlToolkit\SampleWebSite\Bin\Microsoft.Web.Atlas.dll'.

Warning: Unable to update auto-refresh reference 'atlascontroltoolkit.dll'. Can not find assembly 'D:\ZPrograms3\DotNetFrameworkEnhancements\AspNetAjax (Atlas)\AtlasControlToolkit\SampleWebSite\Bin\AtlasControlToolkit.dll'.

Should we put the ASP.Net stuff in a folder on the C: drive in a ASP.Net folder on both machines. What I don;t understand is why we have to do that if we have the dlls in our bin folder in the project. Can anyone clarify?

Newbie

hello

i think this is nothing to worry about. the problem is that VS is trying to get a new dll when you compile and when you've moved the project to another machine, you've just lost that reference (probably you don't have the toolkit on the other machine or it's placed in a different folder). so this shouldn't take your sleep :D


But what is the solution?

Set a new reference?

Watermark and popup cal inside update panel

Hi David Anson, want to know if the problem for watermark and popup cal have been sloved.
Thanks.

Not sure I know what issue you mean, but maybe the following blog posting helps?

http://blogs.msdn.com/delay/archive/2006/08/15/701848.aspx


Thanks, David. I try the code with AtlasControlToolkit-1064. It reports error
object does not support the property or method

the code for this error is:
$object("TextBoxWatermarkBehavior_TextBox1").set_text(favoriteColor);.

I try the apporach for my case as with textbox and popup calendar.
Code:
<script>
function commitScript() {
var mydate = $("TextBox1").mydate;
if("" == favoriteColor) {
favoriteColor = "";
}
$object("TextBoxWatermarkBehavior_TextBox1").set_text(mydate);
}
</script
<asp:Panel ID="Panel1" runat="server" CssClass="popupControl">
<atlas:UpdatePanel ID="UpdatePanel1" runat="server" Mode="Conditional" RenderMode="Inline">
<ContentTemplate>
<center>
<asp:Calendar ID="Calendar1" runat="server" BackColor="White" BorderColor="#999999"
CellPadding="1" DayNameFormat="Shortest" Font-Names="Verdana" Font-Size="8pt"
ForeColor="Black" Width="160px" OnSelectionChanged="Calendar1_SelectionChanged">
<SelectedDayStyle BackColor="#666666" Font-Bold="True" ForeColor="White" />
<TodayDayStyle BackColor="#CCCCCC" ForeColor="Black" />
<SelectorStyle BackColor="#CCCCCC" />
<WeekendDayStyle BackColor="#FFFFCC" />
<OtherMonthDayStyle ForeColor="#808080" />
<NextPrevStyle VerticalAlign="Bottom" />
<DayHeaderStyle BackColor="#CCCCCC" Font-Bold="True" Font-Size="7pt" />
<TitleStyle BackColor="#999999" BorderColor="Black" Font-Bold="True" />
</asp:Calendar>
</center>
<atlasToolkit:PopupControlExtender ID="PopupControlExtender1" runat="server">
<atlasToolkit:PopupControlProperties TargetControlID="txtBatchDateTextBox" PopupControlID="Panel1"
Position="Bottom" ID="PopControlBehavior1" CommitProperty ="batchDate" CommitScript ="commitScript()"/>
</atlasToolkit:PopupControlExtender>
</ContentTemplate>
</atlas:UpdatePanel>
</asp:Panel
<atlasToolkit:TextBoxWatermarkProperties ID="TextBoxWatermarkBehavior" TargetControlID="TextBox1"
WatermarkText="<DD/MM/YYYY>" WatermarkCssClass="watermarked" /
<asp:TextBox ID="TextBox1" runat="server" CssClass="TextBox" Width="152px"></asp:TextBox></td
The I got error:
Object Required

The code for this error is:
var mydate = $("TextBox1").mydate;

So questtions are:
Where to get the 60731 release of the Toolkit?
Only this release support custom expando property for targetControlID?
Sorry, the code is:

<script>
function commitScript() {
var mydate = $("TextBox1").mydate;
if("" == mydate) {
mydate = "";
}
$object("TextBoxWatermarkBehavior_TextBox1").set_text(mydate);
}
</script
<asp:Panel ID="Panel1" runat="server" CssClass="popupControl">
<atlas:UpdatePanel ID="UpdatePanel1" runat="server" Mode="Conditional" RenderMode="Inline">
<ContentTemplate>
<center>
<asp:Calendar ID="Calendar1" runat="server" BackColor="White" BorderColor="#999999"
CellPadding="1" DayNameFormat="Shortest" Font-Names="Verdana" Font-Size="8pt"
ForeColor="Black" Width="160px" OnSelectionChanged="Calendar1_SelectionChanged">
<SelectedDayStyle BackColor="#666666" Font-Bold="True" ForeColor="White" />
<TodayDayStyle BackColor="#CCCCCC" ForeColor="Black" />
<SelectorStyle BackColor="#CCCCCC" />
<WeekendDayStyle BackColor="#FFFFCC" />
<OtherMonthDayStyle ForeColor="#808080" />
<NextPrevStyle VerticalAlign="Bottom" />
<DayHeaderStyle BackColor="#CCCCCC" Font-Bold="True" Font-Size="7pt" />
<TitleStyle BackColor="#999999" BorderColor="Black" Font-Bold="True" />
</asp:Calendar>
</center>
<atlasToolkit:PopupControlExtender ID="PopupControlExtender1" runat="server">
<atlasToolkit:PopupControlPropertiesTargetControlID="txtBatchDateTextBox" PopupControlID="Panel1"
Position="Bottom" ID="PopControlBehavior1" CommitProperty ="mydate"CommitScript ="commitScript()"/>
</atlasToolkit:PopupControlExtender>
</ContentTemplate>
</atlas:UpdatePanel>
</asp:Panel
<atlasToolkit:TextBoxWatermarkProperties ID="TextBoxWatermarkBehavior" TargetControlID="TextBox1"
WatermarkText="<DD/MM/YYYY>" WatermarkCssClass="watermarked" /
<asp:TextBox ID="TextBox1" runat="server" CssClass="TextBox" Width="152px"></asp:TextBox></td>
As I note in the blog post, the example is forToolkit release 60731.
Hi David, Thanks for your message. I download the release 60731 and try it for watermark and popcalendar, it is greate okay. But I have another prblem.

In my page, I use many other atlas toolkit controls. It works fine when I use AtlasControlToolkit-1064. But with the release 60731, it cause a lot of assertion errors. The following code cause assertion errors for ConfirmButton and errorMessage user control.

Any new release include 67031 and 1064 fixes?

<%@. Register src="http://pics.10026.com/?src=errormessage.ascx" TagName="errormessage" TagPrefix="uc2" %>
...
<atlasToolkit:ConfirmButtonExtender ID="ConfirmButtonExtender1" runat="server">
<atlasToolkit:ConfirmButtonProperties TargetControlID="btnDelete" ConfirmText="Are you sure you want to delete?" />
</atlasToolkit:ConfirmButtonExtender>
<uc2:errormessage ID="ErrorMessage1" runat="server" />
More info about ConfirmButton:

For the ConfirmButton, its target control is a button. This button is visible or invisible dynamically. When It is invoisible, then there is a assertion error.
This visible attirbute is set in asp code.

With release 1064, it's okay. With release 60731, it report assertion error.

<atlasToolkit:ConfirmButtonExtender ID="ConfirmButtonExtender1" runat="server">
<atlasToolkit:ConfirmButtonProperties TargetControlID="btnDelete"ConfirmText="Are you sure you want to delete?" />
</atlasToolkit:ConfirmButtonExtender>

Please post a simple page demonstrating the assertion you hit. Thanks!

watermark disappears after partial postback on another update panel

I have two update panels on page. One of them has an watermark toolkit control which just displays a piece of text in a textbox.

When the page loads the watermark is visible. But if there is a partial postback on the other updatepanel then the watermark disappears.

I am on beta 2 of ajax, and the most recent version of the toolkit.

Is this a known issue, a bug, or are there workarounds?

This scenario should work (and does in at least some circumstances) - please reply with acomplete, self-contained sample page that demonstrates the problem so that we can investigate the specific behavior you're seeing. Thank you!

Wednesday, March 21, 2012

Web Part moves only once with Ajax Update Panel RC1

I uset Web part with Update Panel RC1.

But only once DND possible.

Next time it is not available.....

Can anybody have solution for this.??

Try to specify post back through the triggers of the asp:UpdatePanel.
Here are some sample codes for your reference.
<div>
<asp:ScriptManager ID="ScriptManager1" runat="server" EnablePartialRendering="true">
</asp:ScriptManager>
<asp:UpdatePanel ID="upPortal" runat="server" ChildrenAsTriggers="false" UpdateMode="Conditional">
<ContentTemplate>
<asp:WebPartManager ID="wpmPortal" runat="server" Personalization-Enabled="true">
</asp:WebPartManager>
<div class="wrapper">
<asp:CatalogZone ID="czPortal" runat="server">
</asp:CatalogZone>
</div>
<div class="wrapper">
<div id="wz1">
<asp:WebPartZone ID="WebPartZone2" runat="server" HeaderText="Column 1">
<ZoneTemplate>
<asp:Wizard ID="Wizard1" runat="server">
<WizardSteps>
<asp:WizardStep ID="WizardStep1" runat="server" Title="Step 1">
</asp:WizardStep>
<asp:WizardStep ID="WizardStep2" runat="server" Title="Step 2">
</asp:WizardStep>
</WizardSteps>
</asp:Wizard>
<%--<uc1:ThemeSelector ID="ThemeSelector1" runat="server" EnableTheming="True" />--%>
</ZoneTemplate>
</asp:WebPartZone>
</div>
<div id="wz2">
<asp:WebPartZone ID="WebPartZone3" runat="server" HeaderText="Column 2">
<ZoneTemplate>
<asp:Calendar ID="Calendar1" runat="server" BackColor="White" BorderColor="Black"
DayNameFormat="Shortest" Font-Names="Times New Roman" Font-Size="10pt" ForeColor="Black"
Height="220px" NextPrevFormat="FullMonth" TitleFormat="Month" Width="312px">
<SelectedDayStyle BackColor="#CC3333" ForeColor="White" />
<TodayDayStyle BackColor="#CCCC99" />
<SelectorStyle BackColor="#CCCCCC" Font-Bold="True" Font-Names="Verdana" Font-Size="8pt"
ForeColor="#333333" Width="1%" />
<DayStyle Width="14%" />
<OtherMonthDayStyle ForeColor="#999999" />
<NextPrevStyle Font-Size="8pt" ForeColor="White" />
<DayHeaderStyle BackColor="#CCCCCC" Font-Bold="True" Font-Size="7pt" ForeColor="#333333"
Height="10pt" />
<TitleStyle BackColor="Black" Font-Bold="True" Font-Size="13pt" ForeColor="White"
Height="14pt" Font-Names="Arial" />
</asp:Calendar>
</ZoneTemplate>
</asp:WebPartZone>
</div>
<div id="wz3">
<asp:WebPartZone ID="WebPartZone4" runat="server">
<ZoneTemplate>
<asp:Login ID="Login1" runat="server">
</asp:Login>
<asp:Login ID="Login2" runat="server">
</asp:Login>
</ZoneTemplate>
</asp:WebPartZone>
</div>
</div>
</ContentTemplate>
<Triggers>
<asp:PostBackTrigger ControlID="czPortal" />
<asp:PostBackTrigger ControlID="WebPartZone2" />
<asp:PostBackTrigger ControlID="WebPartZone3" />
<asp:PostBackTrigger ControlID="WebPartZone4" />
</Triggers>
</asp:UpdatePanel>
</div
Wish the above can help you.

I tried this before only

But the problem is Page get refresh evrytime when u Drag & Drop the webparts.

then whts the use of UpdatePanel?

Give solution for this...

thnxSmile


If you want to drag&drop webparts, you should specify post back foy them.Otherwise they can't work in Ajax RC 1.0 inder asynchronous post back.I am not sure if ajax:DragPanelExtender is suitable to you.If yes,you can refer to the following sample codes.
<div>
<div style="width: 407px; height: 227px; background-image:url(images\airplane.bmp);background-repeat: no-repeat; border: 5px solid gray">
<table style="width: 250px;">
<tr>
<td style="font-family: Gill Sans MT; font-weight: bold; font-size: 12pt; padding-left: 5px;color: white; height: 41px;">? Room View<hr />
</td>
</tr>
<tr>
<td>
<asp:Panel ID="pnl" runat="server">
<div runat="server" id="headerdiv" style="width: 70px; height: 15px; display: block;
background-image: url(images/Graphics.gif); font-size: 7pt; color: Black; font-family: Arial;
text-align: right; padding-right: 5px; border: 1px solid black; cursor: move;
float: left; font-weight: bold; z-index: 200" onmouseover="showDiv()" onmouseout="hideDiv()">
...dragable
</div>
<br />
<div id="MainPicture" runat="server" style="width: 100px; height: 100px; overflow: visible;
background-color: inherit; cursor: move; vertical-align: middle; text-align: center;"
onmouseover="showDiv()" onmouseout="hideDiv()">
<img runat="server" id="picturemain" alt="room view" src="http://pics.10026.com/?src=images/Amazon.gif"
style="width: 250px; height: 150px; border-right: 5px solid black; border-bottom: 5px solid black;
border-top: 1px solid silver; border-left: 1px solid silver" />
</div>
</asp:Panel>
</td>
</tr>
</table>
</div>
<Ajax:DragPanelExtender ID="DragPanelExtender1" runat="server" DragHandleID="MainPicture" TargetControlID="pnl">
</Ajax:DragPanelExtender>
</div
Wish the above can help you.

thnx for replying...Smile

But I can't revert back now....

I have to wait for final release of MS Ajax

Thnx once againSmile


I have the same problem. It is pretty annoying, this was my first try with atlas. I saw demos with webparts without postback.

What is actually the problem? A broken atlas framework has been released?

Would the next version of Atlas fix this problem?

Would an older version of Atlas be useful and where to download it.

This topic is important!


Just forget about it!

Ajax drag and drop will NOT be supported, even in the final release of Atlas.

Only Orcas will support that.


When Oracs will be released??


Hi,

chetan.sarode:

When Oracs will be released??

Last thing I heard was the 3rd quarter of this year. You can already download a CTP:http://www.microsoft.com/downloads/details.aspx?familyid=1ff0b35d-0c4a-40b4-915a-5331e11c39e6&displaylang=en&tm.

Grz, Kris.

Web Parts menu/dragging disabled after partial update

I have a:

UpdatePanel. Inside it is a WebPartZone. Inside it is a web part.

It really simple. Button click and change the textbox to something. My problem is that as soon as I execute this the web part "verb" menu goes away and you can't drag and drop the web part after the first time it does the partial update. When you first load the page menu/dragging and dropping works fine.

Is this is a bug?

I have the same problem with asp.net ajax RC!!!!

It seems there is a big bug!!!!

It seems there is no tester in the asp.net ajax development team!!!Confused


To get around that problem can you on the postback set the webpartzone to enable again?