Showing posts with label controls. Show all posts
Showing posts with label controls. Show all posts

Wednesday, March 28, 2012

VERY new to asp.net AJAX: Enabling controls based on slection from AutoComplete control

I've been reading all day and I'm not finding the solution to my requirement.

I'm developing a form to enter "lead" information, part of the lead data is the name of their Dr. We maintain a MySql DB with leads and Drs information.

When a user is entering a new lead and they type the last name of the Dr I have a AutoCompleteExtension fetching Dr.s that match the last name. When/if the user selects a Dr. from the list I want to DISABLE the other Dr. related fields (FName, address, etc) and insert the data from the selected Dr. If there is no match found, the user will enter the details for the Dr. (new record).

The main issue I'm struggling with is how to respond (client or server) to the user making a selection from the AutoComplete list and enable/disable and populate the related fields. For example, the user picks a Dr. from the list, I then want to disable all the Dr. detail related fields and set the values with the record from the database.

I'm not sure how I will accomplish this yet, I imagine I would need to set those values from the server side and it would in turn use AJAX to push the values down to the client?

If anyone could give me a little guidance I would really appreciate it, I just need a jump start to get this thing going.

Thanks for reading,
Steve


If you're Textbox that has the AutoComplete extention on it loses focus, why not use the onBlur event to check to see if they used your AutoComplete (which would have text in that textbox). If they did use the AutoComplete, then use JavaScript to disable the other textboxes.


You could use the ItemSelected event of the AutoComplete extender in the client and as RTernier says use JavaScript to disable the other textboxes, you could call a webservice to obtain the remaining information of the doctor, check: http://www.asp.net/ajax/documentation/live/tutorials/ExposingWebServicesToAJAXTutorial.aspx
http://www.asp.net/ajax/documentation/live/tutorials/EmbedScriptFile.aspx For information on using WebServices. You could also use an UpdatePanel, I guess you could call a partial post back from the ItemSelected event, although I'm not an expert in UpdatePanel, but I think it would work (personally I like the webservice way better, but it's a matter of choice).

Very weird error. Ajax controls call default.aspx

I have a few pages in my site... and for some reason, if there's any ajax controls on the page, it calls default.aspx and runs the code every time any aspx page with an ajax control exists on it. Problem is, default.aspx resets my session variables.

Why does Ajax call the default.aspx page code? It only runs the CS file... it doesn't actually show the default.aspx page.

I doubt it calls it. Do you have a component in your site somewhere that's got a url of "/" attached to it somewhere, and that's invoking the default page?


it only seemed to only happen when I have Certain Ajax controls on the page. Note, it only does it with Internet Explorer 6 and 7. Firefox seems to be fine.

For example, I have a collapsible PAnel in each row of a Gridview. That is in an UpdatePanel. When the Gridview is populated (and I have a breakpoint on the default.aspx.cs file), it goes through that code. Well, I set my session variables on that page, so in essence it resets them.

It seems like it does this AFTER the page is loaded, because the labels that show content based on those session variables aren't updated until I go to a new page.

It only does this when I have a collapsible panel in IE. The panel is set to collapsed.


Actually, it appears that AJAX is clearing the Session Variables. I don't know where it's doing this, though.

Viewstate - Controls that are there but not there at the same time

Hi All,

I wonder if someone can help. I have just started using ajax and am converting an established application. It uses dynamically created controls to enter parameters for crystal. I have now got a panel that l holds the crystal component, and with testing of directly fed parameters this works fine. As soon as i try and use my dynamic componenets it can't see them. I have gathered this has got something to do with viewstates. I have seen several examples of how to fix this but they are all in C# and the application is in vb. Can anybody step me through this please as i sem to be missing something.

hello,

show me the examples that you found in C# ... i might be able to convert it back to VB for you ... =)


Ttry this online link for converting C# to VB Code...

http://www.kamalpatel.net/ConvertCSharp2VB.aspx


Hi

My conversion is below,

Protected Overrides Function LoadPageStateFromPersistenceMedium()As Object Dim viewStateAs String = Request.Form("__VSTATE")Dim bytesAs Byte() = Convert.FromBase64String(viewState) bytes = Decompress(bytes)Dim formatterAs LosFormatter =New LosFormatterReturn formatter.Deserialize(Convert.ToBase64String(bytes))End Function Protected Overrides Sub SavePageStateToPersistenceMedium(ByVal viewStateAs Object)Dim formatterAs LosFormatter =New LosFormatterDim writerAs StringWriter =New StringWriter() formatter.Serialize(writer, viewState)Dim viewStateStringAs String = writer.ToString()Dim bytesAs Byte() = Convert.FromBase64String(viewStateString) bytes = Compress(bytes) ScriptManager.RegisterHiddenField(Me,"__VSTATE", Convert.ToBase64String(bytes))End Sub
Public Function Compress(ByVal dataAs Byte())As Byte()Dim outputAs MemoryStream =New MemoryStreamDim gzipAs GZipStream =New GZipStream(output, CompressionMode.Compress,True) gzip.Write(data, 0, data.Length) gzip.Close()Return output.ToArray()End Function Public Function Decompress(ByVal dataAs Byte())As Byte()Dim inputAs MemoryStream =New MemoryStream() input.Write(data, 0, data.Length) input.Position = 0Dim gzipAs GZipStream =New GZipStream(input, CompressionMode.Decompress,True)Dim outputAs MemoryStream =New MemoryStream()Dim buffAs Byte()Dim readAs Integer = -1 read = gzip.Read(buff, 0, buff.Length)While (read > 0) output.Write(buff, 0, read) read = gzip.Read(buff, 0, buff.Length)End While gzip.Close()Return output.ToArray()End Function

And the original code was:

protected override object LoadPageStateFromPersistenceMedium()2 {3string viewState = Request.Form["__VSTATE"];4byte[] bytes = Convert.FromBase64String(viewState);5 bytes = Compressor.Decompress(bytes);6 LosFormatter formatter =new LosFormatter();7return formatter.Deserialize(Convert.ToBase64String(bytes));8 }9protected override void SavePageStateToPersistenceMedium(object viewState)10 {11 LosFormatter formatter =new LosFormatter();12 StringWriter writer =new StringWriter();13 formatter.Serialize(writer, viewState);14string viewStateString = writer.ToString();15byte[] bytes = Convert.FromBase64String(viewStateString);16 bytes = Compressor.Compress(bytes);17 ScriptManager.RegisterHiddenField(this.updVS,"__VSTATE", Convert.ToBase64String(bytes));18 }
thanks again

Monday, March 26, 2012

Visible attribute on Atlas controls

Hi,

This small piece of code doesn't work in the current Atlas CTP:

<div>

<atlas:ScriptManagerID="ScriptManager1"runat="server"EnablePartialRendering="True">

</atlas:ScriptManager>

</div>

<atlas:UpdateProgressID="UpdateProgress1"runat="server"Visible="false">

<ProgressTemplate>

Contacting server...

<br/>

<br/>

<inputid="abortButton"runat="server"type="button"value="Abort Request"/>

</ProgressTemplate>

</atlas:UpdateProgress>

The controls that implement the IScriptObject (UpdateProgress,…) use to override the RenderScript method in order to write xml/script output. The problem arrives when visible="false" for this control; then the control itself doesn't render, but it does the xml/script, what provokes a javascript error. This behavior is by design? Am I correct? Then, how could I override this behavior (and avoid this problem)? One solution could be to unregister the control in the script manager, but there is no ScriptManager.UnregisterControl (control).

Thanks

Fran

Anybody there??

style="display:none;"


Type 'Microsoft.Web.UI.UpdateProgress' does not have a public property named 'Style'

I think it would be great to have a nice Style or CssClass property, but there is nothing like that at the moment.

but that gave me another idea: a div surrounding the updateprogress, and apply the style to the div. it is not really a nice solution, but it works.

thanks

Fran

Visual Studio "Loses" controls inside an UpdatePanel

Hi,

I'm using a couple of UpdatePanels on a page and it seems that Visual Studio periodically loses track of controls that are inside an UpdatePanel, throwing errors that say those controls don't exist. If I restart Visual Studio the problem goes away.

Any ideas?

Thanks!

Anybody?


I am having the same problem here.. no solution yet.
I'm also having this problem, the difference is that re-loading VS doesn't get rid of it.

Visual Studio 2005 Add-in for Atlas

Will there be a Visual Studio 2005 Add-in for Atlas that will provide intellisense and add the Atlas controls to the toolbox?
When will it be available?
Regards,
John

You can add the controls to your toolbox, right-click,... but you will not have any design view support, as I can remember.


There is already some design view support, but it will get much better as we advance.

VS 2008 - Add extender helper icon on controls

I have downloaded and installed VS 2008, .NET 3.5 and current Ajax Control Toolkit. I have added the toolkit to the VS Toolbox.

The little 'helper' arrow, as described in the video linked below (around the 7 min mark), does not appear for me. I add a button to a page, highlight it in design mode and it doesn't show the helper arrow. I can drag and drop an extender from the Toolbox, but it would be nice to have this added functionality as described.

http://asp.net/learn/3.5-videos/video-224.aspx

Am I missing something?

Thanks,
Tim

I have the same problem.

FYI, in addition to the installation process described in the Toolkit instructions I also tried installing them the same way Joe Stagner described in the video you referenced with no success. Joe suggests copying all files/dir in the Ajax Control Toolkit's SampleWebSite\bin directory into the toolkit's Binaries subdirectory, then adding them to the Visual Studio Toolbox from there.


More info:
http://forums.asp.net/t/1184181.aspx

But no solution?


Hi,

Please try the following steps:

1. Download the source code of ajax controltoolkit

2. Open in Visual Studio

3. Open property page for AjaxControlToolkit project

4. Click Assembly Information

5. Change Assembly Version from 3.5.11119.* to 3.5.0.0

6. Rebuild the project and use this assembly in your project

I downloaded the source. When I try to open the AjaxControlToolkit.sln in VS 2008, I get the error "[file path]\AjaxControlToolkit.csproj cannot be opened because its project type (.csproj) is not supported by this version of Visual Studio. To open it, please use a version that supports this type of project."

I cannot open in VS 2005 either. I don't have any other versions of VS.

Am I doing something wrong?

Thanks
Tim


Hi Tim,

Which version of Visual Studio are you using?

Please useVisual C# 2008 Express edition (which is free )or higher (e.g., professional version).

Saturday, March 24, 2012

Want to use AJAX Controls on Web-form...reqt

I m using VISUAL STUDIO.NET in that i m designing the form on ASP.NET with C#.

I want to know that what are the requirement or the tools or software needed to write the code on from using AJAX.

I want to use all the main features of AJAX so pls tell me or provide link for latest update.

You can download ASP.NET Ajaxhere. This will install everything you need for basic Ajax use. You can also consider downloading the Ajax Control Toolkit from the same location.

want to use AJAX Control & .....

Hi everyone

I have developed web application without using AJAX.it is completed.

Now, I want to use AJAX functionality & tool kit controls.

SO, what are changes, I have to make in web.config or a particular web page.

Please help me out,

Regards,
ASIF

Hi,

you can take a look at this page:http://asp.net/AJAX/Documentation/Live/ConfiguringASPNETAJAX.aspx or you can create a new website based upon the AJAX web site template and use a tool like winmerge to copy over the needed differences in the web.config file.

Grz, Kris.


How Do I: Add ASP.NET AJAX Features to an Existing Web Application? : The Official Microsoft ASP.NET 2.0 Site

hope it helps./.

Wednesday, March 21, 2012

Web controls with in th Accordion control

Hi,


Is there a way or an example to put ASP.Net controls and another Ajax controls within the accordion control?.


Thanks.

Marco

this is my own example

<cc1:AccordionPane ID="AP3" runat="server">
<Header>
<a href="http://links.10026.com/?link=" onclick="return false;" class="accordionLink">Section 3</a></Header>
<Content>
<asp:UpdatePanel ID="up3" runat="server">
<ContentTemplate>
<asp:GridView ID="gd2" runat="server">
</asp:GridView>
<asp:Button ID="btnClick" runat="server" Text="Call Database" OnClick="btnClick_Click" />
</ContentTemplate>
</asp:UpdatePanel>
</Content>
</cc1:AccordionPane>

then on the btnClick's click event, I generate gridview from database

so yes. you can have most of control within accordion

Web Form & AJAX Control Toolkit

Hi,

I'm new to ASP.NET AJAX, and I have a few questions.

Can I use the AJAX Control Toolkit on a ASP.NET Web Form? I've tested the controls on the "ASP.NET AJAX-Enabled Web Site" template and they work fine there, but on a web form there's no action.

If its possible, what I must do to enable AJAX on a web form and/or a user control?

Thank youYes

cseven:

Can I use the AJAX Control Toolkit on a ASP.NET Web Form? I've tested the controls on the "ASP.NET AJAX-Enabled Web Site" template and they work fine there, but on a web form there's no action.

If its possible, what I must do to enable AJAX on a web form and/or a user control?

Peace be unto you,

In case of using Asp.net AJAX in web application or website other than AJAX Enable, you need to write following lines under system.web in web.config

 <httpHandlers> <remove verb="*" path="*.asmx"/> <add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/> <add verb="*" path="*_AppService.axd" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/> <add verb="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> <add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/> </httpModules>

If it works let me know ... cheers


Thanks, works like a charm.

I knew that the solution had to be on the Web.Config file.Big Smile

Back to work!

Thank you againYes



cseven:

Back to work!

Thank you againYes

It is glad to know that your work is done, Please pray for me.

Web page and User control

Good morning ladies and gents. I need a help with the following scenario:
I have a web page and two user controls.
a web page(ASPX) namedWebPage.aspx
a user control(ASCX) namedUserControl1.ascx
a user control(ASCX) namedUserControl2.ascx

TheWebPage.aspx has a user controlUserControl1.ascx bind to it and then user UserControl1.ascx hasUserControl2.ascx in it.(See below)
InsideUserControl2.ascx page a have a TabContainer control namedTabs. It has a methodOnClientActiveTabChanged="ActiveTabChanged".
ActiveTabChangedis JavaScript function (see below) inside aUserControl2.ascx

function ActiveTabChanged (sender, e)
{
__doPostBack('<%= Tabs.ClientID %>',sender.get_activeTab().get_headerText());
}
So basically when you switch from one TabPanel to another it should do a post back.
My problem is that Java Script function not getting triggered; it is only fires when I put it intoUserControl1.aspx but now facing a problem like "Tabs"control not exist onUserControl1.aspx .

My question is: How can I executeActiveTabChanged function to get a post back?

Thank you for your help.

Are you sure the real Tab.ClientId is written into the client code. You might want to compare what it is actually writting (you can do this with the source view on IE).


Yes, i did compare what's in the view source and it looks fine to me.

Thanks for reply

Web Server Controls - Basic Requirements To Work with AJAX.NET

Is thereany documentation showing what is required to equip a server-side WebControl to work with AJAX.NET?

I have some VERY simple WebControls that fire "Click" events. One of them consistantly causes the entire page to refresh, while the other doesn't. But they are both doing the same thing. For some reason, one seems tonot work with AJAX.NET, while the other does. Both of them are wrapped inside an UpdatePanel and ContentTemplate - but behave differently under AJAX.NET. Mysterious.

I can't tell if the examples showing ScriptControlDescriptor.AddEvent are relevent for what I'm doing or not. This seems to be related to very specific client side javascript voodoo - I just want to have a generic control that can fire events that will postback to the code-behind (like a normal ASP.NET button, for example - I can drop one of these on a page, use the event, and it just works - but how to do this properly with a custom WebControl - RELIABLY?).

If there is a plain-jane, simple example of a WebControl and the proper way to have it fire events (__doPostBack) without causing the entire page to refresh, that would be VERY helpful.

Thanks.

There's lots of examples of how to do this outside the webcontrol, so to do it inside a webcontrol all you really have to do is embed the javascript in the assembly and make sure that it ends with the if(Sys && Sys.Application) Sys.Application.notifyScriptLoaded(); statement. The easiest way to wire up interaction between your C# class and the javascript is by following the pattern described in the tutorials on custom extenders. children of ScriptControl follow the same basic pattern.

I've looked at the examples. There are too many things illustrated just aren't exlained. Sorry. I just don't have time to read the "Gone With the Wind" to get an answer to a simple question.

Do I have to write special javascript beyond the standard "_doPostBack" to get a postback executed without causing a page update? Why does it work for an asp:Button without doing anything out of the ordinary? Is some kind of magic support wired into ASP.NET for the standard .NET controls?

SIMPLE QUESTION (YES/NO):

Can I write a WebControl that fires events - like I would for a NON-AJAX application - and have it work under AJAX.NET without refreshing the entire page?

I thought that any postbacks generated inside an UpdatePanel/ContentTemplate would be AUTOMATICALLY handled by AJAX.NET. This is what it says in the documentation. Is this true or no?

This is just a YES/NO question.

Thanks (frustrated - about to punt on AJAX.NET and just work with web callbacks...)