Showing posts with label web. Show all posts
Showing posts with label web. Show all posts

Wednesday, March 28, 2012

profileService with anything other than SQL

Let's say there is no SQL Server or SQL Express on the Web Server. How would one go about implementing the whole profile thing? You can supposedly use another source for a provider? Like an XML file or something like that. Has anyone sucessfully done this, or am I the only idiot trying this? I've been scowering Google for a few hours now and I'm no further along than I was 3 hours ago.

Profiles are part of the membership provider in the .net framework. What you need to do is write a custom membership provider.

Here's a good article on what your looking for

http://www.devx.com/asp/Article/29256

Here's my google search term

http://www.google.com/search?hl=en&q=Custom+Membership+Provider+%2B+ASP.net+2.0+%2B+XML


Thanks, but I've decided to go in another direction. I'm going to use cookies instead. They're just easier to use.

As advice, cookies are a dated way to handle things likes that, and you probably should look into newer methods.

What happens, if a user has created a profile, with information about theselves, or the way they like to use your website, and then they log on from a different computer...or clear their cookies?

I understand having to remember all my passwords for every site I visit, after I clear my cookies, but if that website lost all my settings, and personal / profile information just because I cleared my cookies, I'd be pissed.


Well then I would be forced to direct them top a web page picturing a straw, and suggest they suck it up. Mind you I'm not telling you to do that, I'm just suggesting one course of action with comedic twist.

Thanks for your input anyway.

Programatically adding UpdatePanel?

I want to programatically add an updatepanel control on a button click.

I tried adding a reference to Microsoft.Web.Atlas.dll and then creatinga System.Web.UI.UpdatePanel control but the app does not compile - withnamespace does not exist error.

Does anyone know what I should be doing or if this is possible at all?

Thanks !

you would need to import the following

Imports Microsoft.Web.UI

Then, you can create an instance of the UpdatePanel like this:

Dim UP As New UpdatePanel

Hope this works for you.


Thanks it works ... I was using System.Web.UI which was the problem
Now that I have this I'm trying to add content to the updatepanel.

I can set most of the properties, add triggers without problems.

However when I try to execute it - it gives an error saying "A ContentTemplate must be specified".

Whats the easist way to do this. I haven't found any documentation on programatically adding a contenttemplate.

Any help would be greatly appreciated!
I'm looking for the same thing myself and haven't found any answers.
You'll need to create a class that implements ITemplate, create an instance of that and set the content template property to that instance.

try this

protected

overridevoid OnInit(EventArgs e)

{

updatePanel.ContentTemplate =

newCompiledTemplateBuilder

(

newBuildTemplateMethod(CreateAtlasUpdateContent));

}

public

void CreateAtlasUpdateContent(Control container)

{

container.Controls.Add(yourcontrol);

}


dont know if this will come in handy with anyone but what i did to get around the template error was

have a class with the following:

PublicClass AjaxControl :Inherits Microsoft.Web.UI.UpdatePanelProtectedOverridesSub OnInit(ByVal eAs System.EventArgs)Me.ContentTemplate =New TemplateBuilderMyBase.OnInit(e)EndSubEndClass

Then whenever i needed to create a control that was surrounded by the update panel i would inherit this class and could just then put me.controls.add() as usual.

probs useless to you all, but works for me :)


Even if you got past the coding issues, you still can't add an UpdatePanel once InitComplete has fired (which is pretty early in the lifecycle) so you're not going to be able to accomplish what you set out to do, which I think was to add an UpdatePanel dynamically.

HTH

Has anyone been able to dynamically add an UpdatePanel to a page?

I got so far - and then I got the error:

"The UpdatePanel 'panel1'was not present when the page's InitComplete event was raised."

Is there any way around this?

Wade.

Programmatically defining the FilteredTextBoxExtender FilterType Property

Hi there!

I'm toying with the FilteredTextBoxExtender for a web portal we're developping at job, and thought it would simpler to define different data-entry textboxes.

With that objective in mind, I created a web user control that include a FilteredTextBoxExtender, its TextBox, some public properties to access underlying controls properties (like TextBox.Text, FilteredTextBoxExtender.FilterMode, etc.), plus a 'BoxType' private member (Type = internal enum) that's gonna define the different TextBoxes we might need (Postal codes, zip codes, money, Person namem email, and so on...)

Intended use is to simply drag the WUC on a page, define its _boxType member value, et voilĂ !

Problem is, I make a verification in the page_Load event of the WUC regarding the _boxType, and then would set the underlying extender's FilterType and ValidChars properties. But when I try to set a value for the FilterType property, I can't use more than one! The Toolkit references page says that you can use a '[...]comma-separated combination ofNumbers,LowercaseLetters,UppercaseLetters, andCustom[...]' but it won't accept the '+' operator for different FilterTypes, won't cast from string to FilterTypes (and vice versa)..

Anyone knows if that's intended?

Hi,

It's aflag enumeration. In ASP.NET's declarative markup you can specify multiple values with commas, but in C# you use the bitwise or operator |. For example, myExtender.FilterTypes = FilterTypes.UppercaseLetters | LowercaseLetters.

Thanks,
Ted


Thank you so very much, Ted. That did the trick!

And I'll most probably face that behavior a couple of times, thanks for the insight!

Programmatically Scroll GridView Control

I have an AJAX enabled web form with several data-filled GridView controls. The users accessing this web app will navigate the site via touch-screen monitors (i.e.: no mouse). As a result, I need an easy way for them to scroll the GridViews when the data is not visible. I want them to click on a button, which will then accordingly scroll the grid up or down. I have tried all the various combinations of the suggestions that I could find:

GridView.Rows(20).RowState = DataControlRowState.Selected

and

GridView.Rows(20).Focus()

and

GridView.SelectedIndex = 20

and

'Set focus to a hidden button control (column)
GridView.SelectedRow.Cells(5).Focus()

If I could set focus to a particular row, I think it should scroll to show that row. This would be fine, but nothing seems to work. Anyone have any suggestions on how I could programatically scroll a GridView control?

Thanks!

Hi AxeRose,

Did you find any solution for this problem?

I have asimilar purpose and meantime I don't have no idea, how to do this.


No, I never found a solution. I ended up using Paging instead -- which works fine for my situation.

Good luck!


I do not know if this works (and probably only in IE or in everything but IESmile ) but there is a javascript function called scrollIntoView that you could try. Just a suggestion.


Seehttp://forums.asp.net/t/1162570.aspx

You can use the JavaScript function: scrollTo(...)

-Damien


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

prm.add_beginRequest(beginRequest);

function beginRequest()
{
prm._scrollPosition = null;
}
</script>

http://forums.asp.net/t/1156877.aspx

Monday, March 26, 2012

Programming model question for Atlas apps

Hi,

I am designing a new web application and hope to leverage Atlas to make a better user experience than a regular ASP.NET web app. One of my things I hoping to archive to is to eliminate the need to have multiple ASPX pages.

Here is a scenario:

The web page may contain a left navigation panel that contains three links:

  1. Step 1
  2. Step 2
  3. Step 3

If I am to design a regular ASP.NET web app, I would make each of the links point to a separate ASPX page. Each of ASPX will share a common chrome such as header, top navigation panel and left navigation panel, but the main content area will be different. I would use a shared master page for them. The drawbacks of the traditional approach are:

  1. Opening each link will cause screen flickers
  2. There will be network delay from one step to another step that I can not reduce by preloading asynchronously.
  3. Each step will add to the browser history that my designer does not like.

I am hoping that Atlas will allow me to collapse all these ASPX pages into a single ASPX page, but I could not find a good approach. Specifically, I didn't find UpdatePanel useful for my design.

I am very interested to hear suggestions on how to archive my design objective. Thanks in advance.

Wei Zhu

hello.

well, you can use atlas to do this, though i really think that eliminating the history may not be a good thing. for instance, when i go to a web site, i really enjoy using the next and back buttons...and regarding to the delay, i really don't think that a normal asp.net page that has been modified to use atlas will be quicker that a traditional page.


Hi Luis,

Can you tell me how to use Atlas to achive my objective?

Regarding whether it is wise to eliminating IE history, I guess some people like it and some people don'tSmile [:)]. I personally don't have a strong opinion on either. As for the network delay, my thought is that using Atlas, maybe I can preload the UI for the step 2 asyncroulsy while user is still on step 1. However, reducing delay is more of an extra bonus credit, not a requirement.


Wei Zhu,

A simple approach to accomplish what I have interpreted your requirements is this:

Your left navigation could be setup as LinkButton controls.

You could put all 3 "pages" of content into a MultiView control.

On the postback of each LinkButton control, you could dynamically show and initialize all controls on the corresponding "View" of the MultiView control.

Surround all of these controls with an UpdatePanel and the result should be a page that appears to work completely clientside using the Atlas framework.

Hope this helps.

Ryan


Thanks Ryan.

I have considered using MultiView inside an UpdatePanel, but I think it will run into the following problems.

1. If I use Validators in each view, then switch view will cause a postback and the validators on those views that haven't been viewed will raise errors and prevent the postbacks from even happening.

2. This approach does not appear to be scale well as the number of views increase.


OK, I may have found a solution. The solution basically is to create a ASCX user control for each view, then load each user control dynamically using Page.LoadControl() inside a UpdatePanel. I did a quick test and it seems to work, although I still need to try it more.

This solution still does not address how to preload next view. It feel like possible to me, but I don't know exactly how to do it yet.


Have you considered using a Wizard control inside an update panel?

Property value undefined after succesfull web service call

Hello,

hopefully I can explain my problem.

I started to create extended control with ajax control toolkit. Idea is, that I have textfield which works so

that it suggest values every time when user hits key. Like that --> http://www.google.com/webhp?complete=1&hl=en

Now in SearchTextBoxBehavior.js file I have two propertys, which one hold id for listbox which shows suggestions.
(I think in that google example, the control is span or div element.)


Ok, I have succesfully created event, which is occurred when user hits key in textfield. Webservice call is made in bold code line-->

1_onkeyup : function() {
23 var targetButton = $get(this._TargetButtonID);
4 var targetListBox = $get(this._TargetListBoxID);
5
6if(targetButton && targetListBox) {
7 targetButton.disabled =true;
8
9// unescape() convert′s a string to URL-encoded form10 var searchValue = unescape(this.get_element().value);
11
12if(searchValue !="") {
13// Set suggestion visible14 targetListBox.style.visibility ="visible";
15
16MyCompany.WebServices.MySearch.GetDataTableFromWebservice(searchValue,this._onSucceeded);
17 }
18else {
19// Set suggestion hidden when there is no search value inserted20 targetListBox.style.visibility ="hidden";
21 }
22 }
23
24 },
 
Web service call is succesfull, and returns into function:
 
1_onSucceeded : function(Result) {23var targetListBox = $get(this._TargetListBoxID);45var table = Sys.Preview.Data.DataTable.parseFromJson(Result);67...89}
 
Problem is, that in that _onSucceeded function, propertythis._TargetListBoxID is
undefined. In function, where I made web service call, the property was ok, and I could
make instance about control.
 

Hi,

you need to modify the context under which the callback is executed. This can be done with a delegate and the Function.createDelegate method:

MyCompany.WebServices.MySearch.GetDataTableFromWebservice(searchValue,Function.createDelegate(this, this._onSucceeded));



Hi,

it worked, thanks. :)


Yesterday evening I managed to circulate problem, with solution below.

1var inputParams =new Array();2inputParams[0] =this._TargetListBoxID;3inputParams[1] =this._TargetButtonID;4inputParams[2] =this._ListControlTextField;5inputParams[3] =this._ListControlValueField;67MyCompany.WebServices.MySearch.GetDataTableFromWebservice(searchValue,this._onSucceeded,this._onFailed, inputParams);

Hi,

yes, as your code shows, you're passing a context object as the last parameter to the proxy method. This is useful especially if you want to access only certain references in the callback and not the whole instance.


Hi All,

huygens...is there any way you can post your full code? I'm looking to do something similar with the toolkit. Would be greatly appreciated.

Saturday, March 24, 2012

Pulling hair out! Cannot get GridView & Search Button to work with Update Panel

I don't know what else to do. As far as I know, my web.config is set up fine. I get no errors as to the ASP.NET AJAX controls and I feel I have tried everything I know, which isn't much yet about UpdatePanels but there doesn't seem to be that much to know after reading

Here's my code below. When I click the search button, I still am getting a full page postback:

<formid="Form1"runat="server"method="post">

<asp:scriptmanagerid="ScriptManager1"enablepartialrendering="true"runat="server"/>

...more code and then

<tdclass="narrowTableWrapperCell"colspan="8"align="left">

<asp:updatepanelid="gvSearchResultsUpdatePanel"runat="server"updatemode="always">

<contenttemplate>

<asp:updateprogressid="UpdateProgressSearchResults"runat="server">

<progresstemplate>

Working......

</progresstemplate>

</asp:updateprogress>

<asp:buttonid="Search"runat="server"onclick="Search_Click"usesubmitbehavior="false"width="113px"/>

<asp:gridviewid="SearchResults"runat="server"onpageindexchanging="SearchResults_PageIndexChanging"onrowcreated="SearchResults_OnRowCreated"

onsorting="SearchResults_Sorting">

<columns>

<asp:templatefielditemstyle-horizontalalign="left">

<headertemplate>

<asp:checkboxid="cbSelectAll"runat="server"textalign="left"/>

</headertemplate>

<itemtemplate>

<asp:checkboxid="cbRow"runat="server"/>

<asp:hyperlinkid="hyName"runat="server"navigateurl='<%# FormatUrl(Eval("MyID"))%>'text='<%# Eval("FullName")%>'/>

</itemtemplate>

</asp:templatefield>

<asp:boundfielddatafield="Phone"headertext="Phone"htmlencode="False"itemstyle-horizontalalign="left"readonly="True"sortexpression="Phone"/>

<asp:boundfielddatafield="HomePhone"headertext="Other Phone"htmlencode="False"itemstyle-horizontalalign="left"readonly="True"sortexpression="HomePhone"/>

<asp:boundfielddatafield="Email"headertext="Email"htmlencode="False"itemstyle-horizontalalign="left"readonly="True"sortexpression="Email"/>

<asp:boundfielddatafield="AlternateEmail"headertext="Alt Email"htmlencode="False"itemstyle-horizontalalign="left"readonly="True"sortexpression="AlternateEmail"/>

<asp:boundfielddatafield="PrimaryAddress"headertext="Primary Address"htmlencode="False"itemstyle-horizontalalign="left"readonly="True"sortexpression="PrimaryAddress"/>

<asp:boundfielddatafield="ShippingAddress"headertext="Shipping Address"htmlencode="False"itemstyle-horizontalalign="left"readonly="True"sortexpression="ShippingAddress"/>

</columns>

</asp:gridview>

</contenttemplate>

</asp:updatepanel>

</td>

...rest of aspx

My Webconfig:

<?xmlversion="1.0"?>

<configuration>

<!-- ASP.NET AJAX Settings | Do not remove-->

<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"allowDefinition="MachineToApplication"/>

<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"allowDefinition="Everywhere" />

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

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

</sectionGroup>

</sectionGroup>

</sectionGroup>

<!-- End ASP.NET AJAX Settings-->

</configSections>

<system.web>

<!-- ASP.NET AJAX Settings | Do not remove-->

<pages>

<controls>

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

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

<addtagPrefix="ajaxToolkit"namespace="AjaxControlToolkit"assembly="AjaxControlToolkit"/>

<addtagPrefix="iu"tagName="Footer"src="~/Components/Footer.ascx" />

<addtagPrefix="iu"tagName="Header"src="~/Components/header.ascx" />

<addtagPrefix="iu"tagName="Navbar"src="~/navbar.ascx" />

</controls>

</pages>

<compilationdebug="true">

<assemblies>

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

</assemblies>

</compilation>

<!-- End ASP.NET AJAX Settings-->

<httpHandlers>

<!-- ASP.NET AJAX Settings | Do not remove-->

<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"/>

<!-- End ASP.NET AJAX Settings-->

<addpath="ChartAxd.axd"verb="*"type="Dundas.Charting.WebControl.ChartHttpHandler"validate="false" />

</httpHandlers>

<!-- ASP.NET AJAX Settings | Do not remove-->

<httpModules>

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

</httpModules>

<!-- End ASP.NET AJAX Settings-->

<xhtmlConformancemode="Legacy"/>

</system.web>

<!-- ASP.NET AJAX Settings | Do not remove-->

<system.web.extensions>

<scripting>

<webServices>

<!-- Uncomment this line to customize maxJsonLength and add a custom converter-->

<!--

<jsonSerialization maxJsonLength="500">

<converters>

<add name="ConvertMe" type="Acme.SubAcme.ConvertMeTypeConverter"/>

</converters>

</jsonSerialization>

-->

<!-- Uncomment this line to enable the authentication service. Include requireSSL="true" if appropriate.-->

<!--

<authenticationService enabled="true" requireSSL = "true|false"/>

-->

<!-- Uncomment these lines to enable the profile service. To allow profile properties to be retrieved

and modified in ASP.NET AJAX applications, you need to add each property name to the readAccessProperties and

writeAccessProperties attributes.-->

<!--

<profileService enabled="true"

readAccessProperties="propertyname1,propertyname2"

writeAccessProperties="propertyname1,propertyname2" />

-->

</webServices>

<!--

<scriptResourceHandler enableCompression="true" enableCaching="true" />

-->

</scripting>

</system.web.extensions>

<!-- End ASP.NET AJAX Settings-->

</configuration>

You forgot to add triggers. See the other post you sumited on this subject. I gave you an example code for you to use.

Pulling my hair out over System.web.Extensions

I am new to this board so do all please be kind!

I have being programming with ASP for sometime, recently moving to ASP.net. I use Visual Web Developer 2005 (the one downloadable from MS)

I am getting the following error:

CS0234: The type or namespace name 'Extensions' does not exist in the namespace 'System.Web' (are
you missing an assembly reference?)

I have definetly installed the AJAX extensions correctly as when I create a VB page as per the demonstration of adding the time reference, clicking a button to update the label on the page, etc, it works.

However if I switch to an application using a webservice, calling SQL server and using AJAX, I get the error. More information as follows:

Line 1: using System;
Line 2: using System.Web;
Line 3: using System.Web.Extensions; <LINE GIVING ERROR>
Line 4: using System.Web.Services;
Line 5: using System.Web.Services.Protocols;

c:\windows\system32\inetsrv> "C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\csc.exe" /t:library
/utf8output
/R:"C:\WINDOWS\assembly\GAC_32\System.EnterpriseServices\2.0.0.0__b03f5f7f11d50a3a\System.EnterpriseServices.dll"
/R:"C:\WINDOWS\assembly\GAC_32\System.Web\2.0.0.0__b03f5f7f11d50a3a\System.Web.dll"
/R:"C:\WINDOWS\assembly\GAC_MSIL\System\2.0.0.0__b77a5c561934e089\System.dll"
/R:"C:\WINDOWS\assembly\GAC_MSIL\System.Configuration\2.0.0.0__b03f5f7f11d50a3a\System.Configuration.dll"
/R:"C:\WINDOWS\assembly\GAC_MSIL\System.Web.Mobile\2.0.0.0__b03f5f7f11d50a3a\System.Web.Mobile.dll"
/R:"C:\WINDOWS\assembly\GAC_MSIL\System.Xml\2.0.0.0__b77a5c561934e089\System.Xml.dll"
/R:"C:\WINDOWS\assembly\GAC_MSIL\System.Web.Extensions.Design\1.0.61025.0__31bf3856ad364e35\System.Web.Extensions.Design.dll"
/R:"C:\WINDOWS\assembly\GAC_MSIL\System.Drawing\2.0.0.0__b03f5f7f11d50a3a\System.Drawing.dll"
/R:"C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\mscorlib.dll"
/R:"C:\WINDOWS\assembly\GAC_MSIL\System.Web.Extensions\1.0.61025.0__31bf3856ad364e35\System.Web.Extensions.dll"
/R:"C:\WINDOWS\assembly\GAC_32\System.Data\2.0.0.0__b77a5c561934e089\System.Data.dll"
/R:"C:\WINDOWS\assembly\GAC_MSIL\System.Web.Services\2.0.0.0__b03f5f7f11d50a3a\System.Web.Services.dll"
/out:"C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET
Files\ws\69af2fc2\64a4ae07\App_Code.dopzyacv.dll" /debug- /optimize+ /w:4 /nowarn:1659;1699
"C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET
Files\ws\69af2fc2\64a4ae07\App_Code.dopzyacv.0.cs"
"C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET
Files\ws\69af2fc2\64a4ae07\App_Code.dopzyacv.1.cs"
"C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET
Files\ws\69af2fc2\64a4ae07\App_Code.dopzyacv.2.cs"

Microsoft (R) Visual C# 2005 Compiler version 8.00.50727.42
for Microsoft (R) Windows (R) 2005 Framework version 2.0.50727
Copyright (C) Microsoft Corporation 2001-2005. All rights reserved.

~\App_Code\EmployeeService.cs(3,18): error CS0234: The type or namespace name
'Extensions' does not exist in the namespace 'System.Web' (are you missing an assembly reference?)
~\App_Code\Employees.cs(4,18): error CS0234: The type or namespace name 'Extensions'
does not exist in the namespace 'System.Web' (are you missing an assembly reference?)

Where is it all going wrong!!!

Any help greatly appreciated!

Sorry if it doesnt, but does this post help? I remember reading it the other week :)

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


A guy was having a similar issue on a hosted server :)

Cheers,

bobdeveaux


Hi,

I looked at the post after extensive searching of the forum before I decided to post myself.

I cannot see how that solution would work as the compiler seems to be finding System.Web.Extensions in the GAC - it's more a case of when it compiles the code it doesn't seem to like what it is reading!

I created the project in Visual Developer like I originally said. The project doesn't create a 'bin' directory only and 'App_code' one - I have tried creating a bin directory alongside 'App_code' and referencing what I had pasted into that however no joy.

Is it siginificant that the compiler seems to like the web.config file yet the two code files where it find using system.web.extensions throws it?

push data to client/ keep checking the server side for any update to load

hi..

Im developing a web application to be used over the internet (not entranet) that means I have unknown of users accessing my web site.

I need to keep checking the server side every 30sec by creating hidden iframe to keep submiting to the server and check for specific updates( such database table). I think this way will reduce the performance of the server and not accepted!

is it true as I think? there is any other technique to this? is there some AJAX control to use instead?

note: Im fetching a small amount of text from the server

It really depends on your system and the expected number of users. Of course, every time you poll the server it takes some performance but in many cases the rewards outweight the performance hit.There are a lot of sites that do this and its not a huge performance hit if you are just retrieving a small amount of text. I would say go for it if you have the capacity.


Take a look at this: http://encosia.com/index.php/2007/07/25/display-data-updates-in-real-time-with-ajax/

The page method call for polling keeps the traffic level very low, compared to other techniques.

Question about adding data to a databse (Im new to Atlas)

I'm wondering how I use Atlas to dynamically add data to a database using the default.aspx.cs file and not a web service. Any help is appreciated.

hello.

well, you have 2 options (one sucks more that the other :D):

1. use page method

2. use an updatepanel.

Question about AJAX and WCF duplex services

OK, I have some existing WCF services that are working with a thick client download, but now we are trying to add a web front end option. I was able to get the one way services working easily by adding a web service page as a simple wrapper around the WCF calls. Now I need to look at our services that are duplex though. Is there a way to do this with the AJAX libraries that are out now? If not, is there a timeframe for when Microsoft might release the next preview that has WCF functionality added back in? And how stable was the older release that still had WCF functionality? Would it work with the release version of WCF?No unfortunately, ASP.NET AJAX has no support for WCF yet. It will be available in future versions. You can use POX to call WCF services but that will be one way and in that case you also should not have a service contract in your WCF service.
Well, if anyone else is caught in a situation like this in the interim, I found a pretty good workaround, at least for my situation. I actually wrote a second WCF service that acts as an aggregator of the first one. The new service only exposes plain http web services, so I can call it no problem from the AJAX code. The aggregator gets the duplex messages from the main server, so it updates in its memory in real time, and then the web page just polls it every few seconds for updates. It's not perfect, but it does what I need for now.

Question about atlas and web interface update

Is the following scenario possible with atlas:

A web based application is run on a server, so clients use web browser to access it. The application uses inforamation from a database to populate the UI with the information. The information is stored in a database and can be changed either from the application or some other source (lets say another server). Is is possible to update the UI on a user's computer when the database is updated from the other server (the user doesn't need to refresh the screen manualy)?

Thanks in advance,
Marko Vuksanovic.

hello.

well, it's possible, though probably not as you wanted. what you must do is poll the server from the client from x to x seconds and if there's new info, then refresh the client. the most common approach is:

1- wrap the contents that need to be refreshed with an updatepanel

2- call the web service from x to x seconds; if there's new info, then refresh the panel.

question about CascadingDropDown

Hi!

I've started to learn AJAX technology recently and I have such questions about using CDDL:

1. Is it only possible to use it with web services? How could I adopt my present bunch "DDL-ObjectDatasource" ?

2.I've discovered that by simply putting set of my dropdownlists into UpdatePanel makes them to work without pagepostback. Than another question appears - if it works with default AJAX mechanism, why was CascadingDropDown extender invented? What is its particular destination or distinct functionality that it provides?

No ideas or no one faced the same?

1) You need to use WebServices. The interface is simple to use with an existing datasource though. Just query the data and create the value list. It's super-flextible for whatever data-access mechanism you're using. See the walkthrough in the SampleWebSite for an example. CCD isn't a straight databinding, it's a dynamic databinding based on a the values of the parent drop down.

2) The postback isn't the issue. You're still getting a post-back inside the UpdatePanel, it's just not affecting the whole page. The issue with the CCD is the linking of several dropdowns to navigate through a virtual tree of possible values.

Question about generated proxies

I'm looking at the following example where all of the functions calling web services use a common call back function.

http://www.asp.net/AJAX/Documentation/Live/ViewSample.aspx?sref=Sys.Net.WebServiceGenerics/cs/generics.js

I can see how organization might be a little better using the call back function and a switch statement, but are there performance benefits? Which would have better performance, individual call back functions or the all in one version? Are there any other benefits or detriments between the two?

thanks

Nick

There is no performance benifits in using a common callback. You can use the Common Callback when you have to process similar kind of logic for more than one web service call result.

Question about object returned from web service...

I have the following script code:

<

scriptlanguage="javascript"type="text/javascript">

<!--

function

Button1_onclick() {

ret = SimpleService.ReturnDataTable(

"fi","la","te", OnComplete, OnTimeOut, OnError);

return

(true);

}

function

OnComplete(arg) {

document.getElementById(

'Text1').value = arg;

//alert(arg);

}

function

OnTimeOut(arg) {alert("TimeOut encountered when calling Say Hello.");

}

function

OnError(arg) {

<

scriptlanguage="javascript"type="text/javascript">

<!--

function

Button1_onclick() {

ret = SimpleService.ReturnDataTable(

"fi","la","te", OnComplete, OnTimeOut, OnError);

return

(true);

}

function

OnComplete(arg) {

document.getElementById(

'Text1').value = arg;

}

function

OnTimeOut(arg) {alert("Error encountered when calling Say Hello.");

}

function

OnError(arg) {

alert(

"Error encountered when calling Say Hello.");

}

// -->

}

</script>

And this is the webservice method it calls:

publicDataSet ReturnDataTable(String Name,String Last,String Test)

{

DataSet ds =newDataSet();DataTable dt = ds.Tables.Add("RandomTable");DMStoDD dd =newDMStoDD();DataColumn column1 =newDataColumn();

column1.ColumnName =

"Name";

dt.Columns.Add(column1);

DataColumn column2 =newDataColumn();

column2.ColumnName =

"Last";

dt.Columns.Add(column2);

DataColumn column3 =newDataColumn();

column3.ColumnName =

"Test";

dt.Columns.Add(column3);

DataRow row;

row = dt.NewRow();

row[

"Name"] = Name;

dt.Rows.Add(row);

row = dt.NewRow();

row[

"Last"] = Last;

dt.Rows.Add(row);

row = dt.NewRow();

row[

"Test"] = Test;

dt.Rows.Add(row);

return ds;

}

Is there something wrong with the way I'm calling my DataSet/DataTable?

Also, what properties does the client side object 'arg' have?

J

arg should have whatever properties are public on the server-side object (I believe) but only if you have a [ScriptService] attribute on the web service, and only if you have a jsonconverter defined for the data type. The default converter works pretty well for most data types, but seems to choke a bit on certain things. I've never done dataset/datatables (typically I roll my own collection for those applications) but from what I've read you can get a dataset converter if you use the Futures dll and make the appropriate changes to your web.config to suppor tit.

Wednesday, March 21, 2012

Question about using AJAX to update a GridView

I'm pretty new to AJAX, but so far I have managed to get a web page working that calls a web service, and the web service returns an array of objects. I would like to use those objects to populate a GridView. But so far, I have been unable to find a way to do that from the javascript on the page. Is this possible?

Hi Ian,

The Microsoft GridView does not have that ability currently. If you're interested, there are other 3rd party grids out there that currently provide a client-side model for adding rows.

-Tony


hi Ian,

did you tried to use ObjectDataSource? take a look at it this linkhttp://www.gridviewguy.com/ArticleDetails.aspx?articleID=139 may be helpful to you.

regards,

satish.


OK, since there's no easy way to do this now, and I don't have the budget for a pre-packaged control, I just did it manually with good old HTML tables and javascript. Thanks for the help though.

Question About Using Validation Controls after a ASYNC postback

I have been working this issue all day and have yet to get anywhere on it so I thought I would try my luck posting something here.

I have a web form users are suppose to complete and save in order to add new records to the database. There are five form fields that have validation controls assigned to them. The validation controls are displayed in a validation summary control. When the user opens an existing record and the form opens all of the form fields are rendered to the page and the validation works fine even inside the ajax update panel. The issue I have is when a new record is being added.

When a user opens the page to add a new record they only see three of the fields on the form. The user has to first select a value from a drop down control which fires are async-postback which in turn displays the rest of the form fields on the page. Just so I am clear the initial three controls displayed are all tied to a validation control. The remaining to controls that are suppose to be validated are part of the form that is hidden until the user selects a value in the first drop down control.

I am having an issue with the two controls that get rendered after the async-postback. The validation controls assigned to these form controls do not fire. After viewing the source code that is rendered to the browser I have determined that the validation controls are created but they cannot find the client-side code for the controls that are to be validated.

When the async-postback is fired from the drop down and the form is rendered to the client why does the client-side source code not show the now unhiddened form fields?

Like I said all the validation controls work when a user edits an existing record because all the fields are shown when the page loads. How do you get the client-side code updated after the async-postback?

I had a similar problem that I had also posted on the forums to get some answers, but I ended doing the research myself and figuring out a solution—take a look at the last post on the thread for a brief description of the problem and solution (http://forums.asp.net/t/1109901.aspx), if you have time.

One thing that I'll point out is the use of the UpdatePanel, and what is actually placed within UpdatePanels. On an Async. PostBack, the UpdatePanels that are configured to respond to an Async. PostBack for a specific trigger (i.e., onchange event of the drop down box) will have th content within them overwritten, updated, or what have you—either way, new HTML is put into the UpdatePanels. The problem here is that any JavaScript referring to HTML elements within one of these UpdatePanels no longer refer to the same HTML elements before the Async. PostBack. What I had to do in this situation is re-hook the JavaScript with thenew HTML elements within the UpdatePanels.

By reading the description of your page, this seems to be the case. The reason why the validators work on existing records is because all HTML elements are rendered at the same time as the initializing JavaScript attached to these elements. However, when creating a new record, the JavaScript is executed before the other two hidden fields are displayed, and hence the initializing JavaScript intended for these two fields are referring to null objects—that is if the hidden fields are not actually rendered in the HTML. When the user selects an item from the drop-down boxes, which fires the Async. PostBack, it is important to note that only the HTML within the UpdatePanels gets re-rendered, the rest of the page does not. Thus, the initializing JavaScript does not run again.

It may be worth your while to take a look at the ASP .NET AJAX Async. PostBack Page-Cycle listed here:http://ajax.asp.net/docs/overview/PageRequestManagerOverview.aspx. I found it to be very helpful. Also, take a look at how Partial Page Loading works to get a better understanding of the UpdatePanel idiom:http://ajax.asp.net/docs/overview/PartialPageRenderingOverview.aspx.

Hope this helps.


delta1186:

Like I said all the validation controls work when a user edits an existing record because all the fields are shown when the page loads. How do you get the client-side code updated after the async-postback?

Sorry, I did not read this question. I would take a look at the link I posted to the PageRequestManager (http://ajax.asp.net/docs/overview/PageRequestManagerOverview.aspx) which, again, explains the life cycle of async. Postbacks but also how the PageRequestManager object, provided by AJAX ASP .NET, can be used to execute custom JavaScript during the life-cycle events. What I did to re-hook my JavaScript with the new HTML elements in my UpdatePanels is I wrote a function that basically uses the JavaScript getElementById function to reassign the HTML element to the JavaScript variable.

My situation was a bit different than yours in which I wrote all the JavaScript for the functionality of my custom user control, so it was easy for me to "re-hook" things together. However, in your case, you're using ASP .NET server controls with ASP .NET AJAX, so I am not too sure how HTML elements are actually hooked into the JavaScript. The PageRequestManager is a good start though. Maybe do a bit of digging around on the MSDN websites and ASP .NET AJAX documentation for an initialize function, and reexecute that function during the endRequest event (http://ajax.asp.net/docs/ClientReference/Sys.WebForms/PageRequestManagerClass/PageRequestManagerEndRequestEvent.aspx) of the async. postback page cycle.

Good luck. Let me know how it goes.


Hi,

The validators are not compatible with UpdatePanel, please try to usethis version instead.

Hope this helps.

Question in regards to deploying AJAX enabled application to Windows 2003 server

I have developed an AJAX enabled web site on a Vista machine. The page I will be refering to contains ScriptManager, UpdatePanels and CollapsiblePanel. This page works fine on the local machine. However when I deployed this application to a Windows 2003 server (Framework 2.0 and ASP.NET 2.0 AJAX Extensions 1.0 installed) and try to invoke it, I get the following error. Any help will be appreciated.

--------
Windows Internet Explorer
--------
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, HttpModules, or server trace is enabled.

Details: Error parsing near '<!DOCTYPE HTML PUBLI'.
--------
OK
--------

Are you using a Firewall on the server, I've seen issues with some firewalls and a setting "Remove Unknown Headers"

Check outhttp://alpascual.com/blog/al/archive/2007/04/26/How-to-fix-Sys.WebForms.PageRequestManagerParserErrorException-in-AJAX.aspx for a potential fix.

Also see this:http://weblogs.asp.net/leftslipper/archive/2007/02/26/sys-webforms-pagerequestmanagerparsererrorexception-what-it-is-and-how-to-avoid-it.aspx for help on debugging the issue.

-Damien

Question on DynamicUpdate properties...

When using this feature - my understanding is that the principle around it is to use a web service.

Say for a popup form modal or otherwise... one was to use it...

how do you go about setting security principles and otherwise preventing someone that shouldn't have access to it beyond the mere fact you can authenticate prior to...my concern is security using this feature...are there any examples to look at that do not use the profile services that guards against someone using a tool like fiddler from manipulating and querying or otherwise being able to submit when using Atlas dynamic behaviors in this manner?

I'm not sure I understand what security issues you feel DynamicPopulate introduces (that aren't already present). Could you outline a scenario, perhaps?

Question: Report Viewer Control (SSRS) inside an Update Panel Control

Hi All,

My web application displays a report on one of its .aspx webpages coded in C#.

I am currently using a ReportViewer control to diplay the server report. I was trying to avoid the refresh of my report on every postback, by including it inside an AJAX Update Panel, it didn't work.

In my next trial, I tried to create a new report viewer control instance programatically and set its properties accordingly and then add this control to the Update panel'sContentTemplateContainer.Controls collection.

It looks like the control gets added to the Update Panel, however, It won't display on the page when it gets renedered. Below is a code snippet.

Please suggest. Thanks.

this.ReportViewer =newReportViewer();

this.ReportViewer.ID ="rvID";

this.ReportViewer.ServerReport.ReportServerUrl =newUri("http://ReportServer");

ReportParameter[] parm =newReportParameter[6];

parm[0] =newReportParameter("a","5");

parm[1] =newReportParameter("b","160");

parm[2] =newReportParameter("c","NYP-BOS");

parm[3] =newReportParameter("d","Coach");

parm[4] =newReportParameter("e","2007-01-01");

parm[5] =newReportParameter("f","2007-05-25");

PanelReport.ContentTemplateContainer.Controls.Add(this.ReportViewer); (adding the Report Viewer to the Panel)

this.ReportViewer.ShowParameterPrompts =false;

this.ReportViewer.ServerReport.SetParameters(parm);

this.ReportViewer.ServerReport.ReportPath ="/Reports/Report1";

Hi!

You should set theAsyncRendering="true"property of the ReportViewer (or setReportViewer.AsyncRendering =True in code-behind) to get async postbacks.

In that way, the report runs in an IFRAME which only refreshes when you re-render the report.

Let me know if it works for you or if you need the reports running in sync with the page. Some time ago I managed to use an UpdatePanel around them, but I ran into some issues that made me come back to the asyncrendering solution.


Hi, Thanks for the response, I have tried using that. It didn't work.

What I have is a Dropdown control, with Autopostback set to true; and an UpdatePanel somewhere else on the page. (the contenttemplate and triggers are empty on the .aspx page)

Programatically, inside the SelectIndexChange evenhandler for the dropdown, I am creating a ReportViewer control and set its properties as needed (also AsynRendering = true).

Now, I add this ReportViewer control to the control collection of the ContentTemplateContainer of the UpdatePanel.

I might be wrong in the sequence of the steps that I am doing...or something else, but whats happening is on the page I can see the report viewer template showing up which has 0 pages.

How and when does the report viewer control or the report gets rendered in the life cycle?

Thanks.


Hi!,

Yes, that may be the problem. The thing is that the SelectedIndexChanged gets fired even after the Page_Load, I'm not exactly sure "when" you have to generate the report, but could be too late. And a ReportViewer in asyncRender won't work inside an UpdatePanel, remeber that is actually an IFRAME.

But, if you are trying to fire an async postback for the SelectedIndexChanged event, the drop down list is the one that should be inside an UpdatePanel (you may already have that).
If that's you case, what you could do is add the ReportViewer outside the update panel and assign its properties in the markup code, and then call theReportViewer.ServerReport.Refresh() method on the SelectedIndexChanged event. If the ReportViewer is set to AsyncRender=true, you should have the same behavior as if it was inside an UpdatePanel.

Hope that helps,


Hi Juan, Based on your response I had partial success.

I made the following changes (Please note that my dropdown list is the first in a set of 3 cascading dropdown lists and all these are not inside any Update panel. They are working as expected whenever the selection changes on the first dropdown.

Took out the ReportViewer control from inside the Update panel and set the properties declaratively (AsyncRendering="true",ProcessingMode="remote",ShowParameterPrompts="false"and also added a <ServerReport> element with correct url and report path


Hi!, Well, I'm glad you are making some progress! :)

Mmmm...I'll start form your second question, and the answer is yes: You have to send the parameters set every time the report is generated.
Another option would be to use the embedded Report Parameters prompts, but it seems that you don't want to do that....
Remember that you can use ServerReport.GetParameters to get all you parameter info.

About the first one, what do you mean exactly when you say "the Report is not refreshing"?? Is trying to refresh, showing the "Generating Report" animated gif and then comes up blank?? It doesn't do anything at all? It comes up with an error??


Hey, that was quick! :)

Yes, I don't want the embedded parameter prompts.

Correct me if I am wrong, ServerReport.GetParameters gives me a readonly collection of parameter info objects right? what could I do with it?

Coming to the first question, By "not refreshing" what I meant was that the webpage sits with the report that it showed me on initial load, even on subsequent SelectIndexChange events (using debugger I can see the event being fired and the parameters being set and the call to report refresh). Its shows me the same report as If nothing happened, (the screen doesn't even flicker) I see the animated gif only on the initial page load.

I think..I would pick "doesn't do anything at all" from the choices that you have listed :)).

Thanks.


Hi!

Well, with the GetParameters you can get the Parameters Name, DataType, DefaultValue, etc,etc.
It's more useful if you want to dynamically create a toolbar or if you want to check that you are entering (SetParameters) all the required parameters with the right names, etc. You can build an array of Parameters and the use it's properties as reference in the SetParameters function.

About the report not refreshing, I would say that it's too late in the page life cycle to do that (as you can see, the SelectedIndexChanged event fires after Page_Load)
Having had a look at my solution, I saw that I'm refreshing the report on Page_Load avoiding to check for Page.IsPostBack.
Just to check, could you try NOT to refresh the report on SelectedIndexChanged and have a Button or something that refreshes the Report AFTER all the appropiate selections have been made in the DropDownLists? Just remember to move the code that sets the parameters and refreshes the reports to Page_Load.

Give it a try, if it works, you'll have the reason for your problem, altought maybe not the solution! :)

Cheers,


Based on the suggestion, I removed the code from the selectindexchange handler and placed something like the below in my page_load to test if the timinig in the lifecycle for the report refresh is the problem. I passed hard coded values to the parameters just so to make sure that the report output generated is different. The initial load was still good but not the postback, nothing happened on postback even from within the page_load. Sorry for all the trouble...I am desperately trying to get this working so as to complete an important assignment by this friday. Thanks.

page_load(object, EventArgs)

{

if (!IsPostback) /* Initial load*/

GenerateReport("a", "b", "c"); (some dummy values for this post)

else

GenerateReport("e", "f", "g"); // on postback

}

void GenerateReport( x,y,z)

{

reportparmeter [] parm = new reportparamete[3];

parm[0] = ..., parm [1] = ...; parm [2] = ...;

reportvwr.ServerReport.Setparameters(parm);

reprtvwr.ServerReprot.Refresh();

}


Mmmm..weird.......how are you generating the second post-back? Are you using a regular post back control like a Button outside an UpdatePanel?


I set the Autopostback on the first dropdownlist to true declaratively. I have a menu on my page too, so I can click on one of the menu items to generate a postback. In this case, should it matter how the postback is fired, because the page_load has hard coded calls for the report generation.

By the by, should the Asynrendering be set to true? (I have it set to true). I can't think of anything else..for now...ok time to go to work.

-Thanks


Hi Juan,

I noticed something, my report refreshes on only normal postbacks and not the asyncpostbacks. Is it okay to assume that, postbacks coming from any controls that are in some way related to an update panel (in or out of it) are always asyncpostbacks?

Thanks.


Hi!

Well, yes, that was the reason of my previous question: The reports will refresh only on a regular postback. If the control that fires the post back is not inside, but set as a trigger for some other update panel, it will fire an async postback.
If you put any control in a page, not inside and not associated with any UpdatePanel, a fire a postback from there, the reports work?

Cheers,


I have a hovermenu extender on my page not part of a update panel. The panel for the hover menu has a couple of link buttons. When I click those link buttons, a normal postback happens and my report gets refreshed.

This is so confusing, I am hoping that there is a thumb rule(s) of some kind for keeping things clear and simple with AJAX (or do's and don'ts). I am new to AJAX and I was wondering if you could recommend me a good design guide which says, how a particular functionality can be accomplished. Right now, I am just developing the code as I discover things, I am afraid if I end up making the code so inflexible for future changes.

Thanks.


What you are experiencing is exactly the same as I was:
The Reports could not be generated as a part of an async postback and in order to make them work properly they should be refreshed not later than in Page_Load...These could be two rules of thumb.

Keep in mind that the ReportViewer runs in a IFRAME while in asyncRendering=true, so it may be worthwhile investigating the interactions between these and AJAX...