Showing posts with label form. Show all posts
Showing posts with label form. 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).

ViewState of CollapsiblePanelExtender

I have several collapsible panels on a web form, and I cant seem to get them to remember their viewstate. Am I missing something or is this not possible?

Here is an example:

<asp:Content ID="Content2" ContentPlaceHolderID="DetailContentPage" Runat="Server"><div style="margin-left:10px"> <asp:Panel Width=100% ID="mainPanel" runat=server > <table width=100% align="left" cellspacing=0 cellpadding=10 > <tr> <td> <asp:Panel ID="ResHeaderPanel" runat="server" CssClass="formPanelHeader" Height="32px"> <div style="padding:5px; cursor: pointer;" > <div style="float:left; margin-top:4px;"> <asp:Image ID="imgResArrow" runat="server" ImageUrl="~/images/expand.jpg"/> </div> <div style="float:left; margin-left:6px; vertical-align:middle;">Engine Settings</div> <div style="float:left; margin-left:30px; margin-top:4px; font-size:x-small" > <asp:Label ID="lblResHeaderHint" runat="server">(Show Details...)</asp:Label> </div> </div> </asp:Panel> <asp:Panel ID="ResPanel" runat="server" CssClass="formPanel"> <table> <tr> <td width=200px>Number of Rooms:</td> <td width=70%><asp:TextBox ID="txtNumRooms" runat="server" MaxLength=200 width=70% /></td> </tr> <tr> <td>Time Zone: </td> <td><asp:TextBox ID="txtTimeZone" runat=server MaxLength=200 width=70%/></td> </tr> <tr> <td>form controls removed </td> <td></td> </tr> <tr> </table> </asp:Panel><!-- ******************************** --> <asp:Panel ID="ContactheaderPanel" runat="server" CssClass="formPanelHeader" Height="32px"> <div style="padding:5px; cursor: pointer;" > <div style="float:left; margin-top:4px;"> <asp:Image ID="Image1" runat="server" ImageUrl="~/images/expand.jpg"/> </div> <div style="float:left; margin-left:6px; vertical-align:middle;">Contact Details</div> <div style="float:left; margin-left:30px; margin-top:4px; font-size:x-small" > <asp:Label ID="lblContactHeaderHint" runat="server">(Show Details...)</asp:Label> </div> </div> </asp:Panel> <asp:Panel ID="ContactPanel" runat="server" CssClass="formPanel"> <table> <tr> <td width=200px>Address:</td> <td width=70%><asp:TextBox ID="txtAddress1" ReadOnly=false runat="server" MaxLength=200 width=70% /></td> </tr> <tr> <td>Address: </td> <td><asp:TextBox ID="txtAddress2" runat=server MaxLength=200 width=70%/></td> </tr> <tr> <td>form controls removed </td> <td></td> </tr> </table> </asp:Panel> </td> </tr> </table> <ajx:CollapsiblePanelExtender ID="cpeRes" runat="Server" TargetControlID="ResPanel" ExpandControlID="ResHeaderPanel" CollapseControlID="ResHeaderPanel" TextLabelID="lblResHeaderHint" ExpandedText=" " CollapsedText="(Click to Show Details...)" ImageControlID="imgResArrow" ExpandedImage="~/images/collapse.jpg" CollapsedImage="~/images/expand.jpg" EnableViewState=true SuppressPostBack="true" /> <ajx:CollapsiblePanelExtender ID="cpeContact" runat="Server" TargetControlID="ContactPanel" ExpandControlID="ContactHeaderPanel" CollapseControlID="ContactheaderPanel" TextLabelID="lblContactHeaderHint" ExpandedText=" " CollapsedText="(Click to Show Details...)" ImageControlID="imgContactArrow" ExpandedImage="~/images/collapse.jpg" CollapsedImage="~/images/expand.jpg" EnableViewState=true SuppressPostBack="true" /> </asp:Panel></div></asp:Content>
 
 
 -Steve 


I'm assuming your saying that when you open one, the other one closes. If so, try this: remove the "EnableViewState=true" from your code and wrap the entire thing in an update panel. I have similar yet I have no troubles with it but mine is wrapped in an update panel.


Thanks for the reply,

That is not quite what I was aiming for. I just wanted the state (open or closed) of the panels to be preserved after postbacks and navigation in my application.

I have a large form, that fills even a high res screen, I split the form into several collapsible panels, so that the user can show and hide the sections that are interesting. Then as the user navigates application records, and postbacks occur, I wish the state of each panel to be preserved.

Maybe I need to manually store the state to the Session and I am misunderstanding the scope of view state?


-Steve


If I understand correctly the panels are closed when you do a postback. This is because a postback reloads the controls. You want to do a partial postback, not a full postback. Therefore, wrap everything in an UpdatePanel, set the updatepanel's updatemode="conditional" and set the ScriptManager to enablepartialrendering="true"

This will cure the headache of a postback. Also with navigation it will have to be in updatepanels. Anything that does a postback must be eleminated and moved into the AJAX portion using update panels and such, otherwise the page will do a complete postback. Overall, the logic behind how things are to be setup with AJAX is a bit more work but the results is well worth it.

^_^


Thanks for the advice, this is the effect that I want to acheive, however I am using a Master page with content pages, linked to a site map based navigation. I trawled the web and could find no examples of the kind of site templete being used with AJAX.

Do have any advice for trying to achieve this? Otherwise the best solution would be to store the panels state to the Sessions, although this seems clunky and I would have thought that the controls would respect viewsate acress postbacks.

-Steve

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.

Watermark + Textbox Issue

I have a web form with a text box with an associated watermarktextbox extender and a button. The goal is to have the user input a name into the the textbox and then use that value when the button is clicked as parameter to a new web page. This works if i remove the watermarktextbox extender. Any assistance would be appreciated.


Do you want a watermark? What exactly do you want to do? Are you receiving errors?


Sorry for the vague original post. Yes, the goal is to have a watermarked textbox. The user enters data into the textbox and I want to use that data as a parameter to a redirection to a new webpage. The problem is that when I use the watermarked textbox the textbox text is not captured (i.e., my parameter is empty). If I use a standard textbox, I'm able to retrieve the textbox text and use it as I intend. I receive no errors I just get an empty value. I'm guessing I need to change the way I get the value of the textbox (client-side script?) but I have no idea how to do this.

Thanks.


OK. Post the script that your using.


Hi,

It's hard to tell without knowing how do you pass value? Are you using queryString? Or PostBackURL?

Please be more specific, a simple repro is preferred.

Watermark text

I created a practice atlas website, put a textbox on the form, dragged the script manager and watermark control to the form. Went to the properties of the textbox and the watermark referance was there with a plus sign. Clicked on the + sign and nothing was there, I could not insert any text. What am I missing? Thank you.I got it working locally but receive this error on the remote server.

Unknown server tag 'atlas:ScriptManager'.
It seems like maybe the remote server's not seeing the Atlas DLL as registered? Maybe check that there's an @.Register for it or a corresponding entry for it in the web.config on that machine.

Wednesday, March 21, 2012

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.