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

Wednesday, March 28, 2012

ProfileScriptService Explanation

Hi,

I'm trying to understand and know all new controls Atlas has. By now, I made some examples with AutoCompleteExtender and DragOverlayExtender and all work well.

But, 'm trying to do something with ProfileScriptService and I don't know how it works. I searched information in google, in some blogs for Atlas and found one post in asp.net forum telling about other control in which there is a ProfileScripService control declared. I tested this example but I can't understand the functionality of this control.

Can someone tell me something about ProfileScriptService??

Thanks.

I am in the same boat, I am trying to get the profile script service samples from the presentations on the web to work, but they just don't work. TTYL.

hello.

well, it's just a custom proxy which wraps calls made over a web service defined in the atlas dll. so, what can you do with it? well you can get or save the properties of your profile that have been atlas enabled. to enable a property to be used, you must add it explicitly to the profileService element in the web.config file.

then, on the client side, you get the profile info by calling the load method (btw, you should also add a handler to the loaded event so that you'll be notified when the properties are loaded). to save eventual property changes, you have 2 options: autosave (in this case, you don't have to do anything) or the manual save( calling the save method).

to explain all these aspects, here's a simple example. suppose your asp.net profile has these properties:

<profile enabled="true">
<properties>
<add name="Nome" type="System.String" />
<group name="Morada">
<add name="Rua" type="System.String"/>
<add name="Porta" type="System.String"/>
</group>
</properties>
</profile>

and you want to access all of them on the client side. so, you must also add these lines to activate the atlas profile service:

<profileService
enabled="true"
setProperties="Nome; Morada.Rua;Morada.Porta"
getProperties="Nome; Morada.Rua;Morada.Porta" />

and now, you can build a simple page to get them and change them. here's some simple html that defines the page structure:

<atlas:ScriptManager runat="server" ID="manager" />

<span>Primeiro nome:</span><input type="text" id="nome" />
<br />
<span>Rua:</span><input type="text" id="rua" />
<br />
<span>Porta:</span><input type="text" id="porta" />
<p></p>
<input type="button" id="modificar" value="Actualizar perfil" onclick="actualiza()" disabled="disabled" />

and here's the jscript that might be used with it:

Sys.Application.load.add( onload );
function onload( sender, eventArgs )
{
Sys.Profile.set_autoSave( false );
Sys.Profile.loaded.add( onProfileLoaded );
Sys.Profile.saved.add( onProfileSaved );
Sys.Profile.load();
}

the profile properties are loaded after the page has loaded everything. i've also disabled autosave and set 2 handlers for the loaded and saved events. During the loaded event, i fill the controls; during the saved event, i show an alert which says that everything has been sa

function onProfileLoaded( sender, eventArgs )
{
$("nome").value = Sys.Profile.properties.Nome;
$("rua").value = Sys.Profile.properties["Morada.Rua"];
$("porta").value = Sys.Profile.properties["Morada.Porta"];

$("modificar").disabled = false;
}

function onProfileSaved( sender, eventArgs )
{
alert( "Dados perfil guardados");
}

function actualiza()
{
Sys.Profile.properties["Nome"] = $("nome").value;
Sys.Profile.properties["Morada.Rua"] = $("rua").value;
Sys.Profile.properties["Morada.Porta"] = $("porta").value;

Sys.Profile.save();
}

btw, some important observations:

* the property group sintax must use the [ ] operator
* though you can use this service from xml-script, there's currently several limitations when you have proeprties and subproperties
* pay attention if you use datetime values

programmatically add calendarextender

hey all,

is this possible to attach a calendarextender control to a textbox? i'm trying to build all my controls dynamically and i'm having problems with postback/async callback behavior. Mainly not understanding what's going on? anyone have any good references on how to do this? That is, build all controls dynamically with some ajax mixed in?

thanks,

rodchar

rodchar:

is this possible to attach a calendarextender control to a textbox? i'm trying to build all my controls dynamically and i'm having problems with postback/async callback behavior. Mainly not understanding what's going on? anyone have any good references on how to do this? That is, build all controls dynamically with some ajax mixed in?

You certainly can do that.

You will just have to create an instance of the calendarextender, assign it the textbox id to its targetcontrolID property. Also make sure this web page/user control has reference to the AJAX tool kit assembly

e.g.

//first add textbox dynamically and give it an IDTextBox myTextBox =new TextBox();myTextBox.ID ="txtCalendar";//now add the calendarExtendar and assign the targetcontrol IDAjaxControlToolkit.CalendarExtender myCalExt =new AjaxControlToolkit.CalendarExtender();myCalExt.TargetControlID = myTextBox.ID;//add both controls to the form/panel control collectionthis.Form1.Controls.Add(myTextBox);this.Form1.Controls.Add(myCalExt);
/

Programmatically Adding Controls and Events

Hi, I am trying to add several link buttons to a page programmatically with the following code:

int i;
int i;
for (i = 0; i < 60; i++)
{
LinkButton lnk = new LinkButton();
lnk.ID = "region" + i;
lnk.CssClass = "mystyle";
lnk.Click += new System.EventHandler(lnk_Click);

addContent.Controls.Add(lnk);

}


which adds them perfectly, however I also want to add an event handler to them all (the same event handler) which I had hoped to achieve by adding the ' lnk.Click += new System.EventHandler(lnk_Click);'
however when the link buttons are now clicked the page freezes, any suggestions?

All that is assigned on the onclick event is a write out to a label within an ajax.net update panel.

Any help would be appreciated, cheers Jon

I set this up in my dev environment and wa sunabel to duplictae it. Can you post more of your code... the ASP and the code behind to give us a better idea of whats going on.

I got the code working - for some reason the fact that the linkbuttons were placed inside a updatepanel and that the 'childrenastriggers' set to true seems to cause the slow down.

I think i know the problem but i am not sure how to solve it!

basically my onload function generates around 1500 linkbuttons in tiny squares within an update panel, each assigned a unique ID.

onclick of each button it posts its unique number to a textbox (temporarily so i can see if it is doing something) it takes around 60 seconds to do this when the 'childrenastriggers' is set to true.

When this is not set to true it performs it instantly, which is fine, however what I am trying to achieve that on click of the linkbutton it puts the number in the box, and changes the css of the linkbutton, updates so the user can see it has changed.

However the update panel is refreshing the generation of 1500 link buttons - which is causing the slow down.

Without the update panel refreshing, and if i cause a full postback the change is instant.

Any ideas on how to get around this but still achieve something similar.


Try and place your button generation code in the Page_Init event.


worked a treat, thank you!

Programmatically created Submit button on UpdatePanel want fire without The UpdatePanel be

I have programmatically created some controls(labels, buttons) that make up and object in several rows of a table on an UpdatePanel. On the initial load of the page, I create all the objects(controls). Then I click one of the buttons to do a partialrendering update of some the controls in the UpdatePanel. The button click causes a post back which I throught was good. The problem is that if i do not refesh the entire set of controls on the UpdatePanel first, the button click want fire and I can't firgure out why.

Here is some of the code:

<asp:ScriptManagerID="ScriptManager1"runat="server"EnablePartialRendering="true"AsyncPostBackTimeout="36000"/><asp:UpdatePanelID="UpdatePanel2"runat="server"ChildrenAsTriggers="false"UpdateMode="Conditional"><ContentTemplate><asp:TableID="Table1"runat="server"></asp:Table><asp:UpdateProgressID="UpdateProgress"runat="server"AssociatedUpdatePanelID="UpdatePanel2"><ProgressTemplate>

Processing Service Request .........

</ProgressTemplate></asp:UpdateProgress></ContentTemplate></asp:UpdatePanel>

protectedvoid btnSubmit_Click(object sender,EventArgs e)

{

RefreshStatus(); --> Causes controls to be built on UpdatePanel.

}

protectedvoid Page_Load(object sender,EventArgs e)

}

if (!IsPostBack)

{

}

else

{

<-- If I do a"RefreshStatus();"here, all works fine but the entire set of controls on the UpdatePane is re-Built. Not what I want.

}

Button Click:

void ChangeStatus_Click(object sender,EventArgs e)

{

Button ChangeStatus = (Button)sender;

----- Update subset of controls on UpdatePanel here -------

}

Since there is no ReFreshStatus() during the postback the button wantfire and nothing happens. I am puzzel by this.

Any Ideas?

Thanks

I forgot mention the each button is built with a AsyncPostBack trigger, ie:

// Add Updatepanel Triggers for the buttonAsyncPostBackTrigger trigForBtns;

trigForBtns =

newAsyncPostBackTrigger();

trigForBtns.ControlID = ChangeStatus.ID;

trigForBtns.EventName =

"Click";

Thanks again, I really need some help with this.


I just wanted to mention that I solved this problem byImplementing Ajax incremental asynochronous updating of controls on the web page.


Thats niceSmile

Can you post some code details here ?

Programmatically creating UpdatePanel and creating Triggers

I'm connecting to a database to get a number then using a for loop to create multiple sets of controls. I'm generating a textbox (which happens to use an AutoCompleteExtender) then adding an EventHandler for that text box which updates a RadioButtonList by connecting to a database. I'm rendering the RadioButtonList in a new UpdatePanel control. Then I'm using the .RegisterAsyncPostBackControl() method for my scriptmanager to get async postback for the new update panel.

The only way I could get the EventHandler to fire is if I manually set .AutoPostBack = true for the TextBox. I'm assuming this is why the whole page posts back instead of just the UpdatePanel.

I'm completely new to these Ajax tools. I'd like to figure out a way to make only the contents of the update panel (the RadioButtonList) to update instead of the entire page. Here's some of my code:

protectedvoid Page_Load(object sender,EventArgs e)

{

// Code to connect to the database to get a value for numCoupons...

for (i = 0; i < numCoupons; i++)

{

Panel pnl =newPanel();pnl.ID ="pnl_" + i;

defaultCoupons_pnl.Controls.Add(pnl);

TextBox couponTitle =newTextBox();

couponTitle.ID ="couponTitle_" + i;

pnl.Controls.Add(couponTitle);

couponTitle.AutoPostBack =true;

couponTitle.TextChanged +=newEventHandler(couponTitle_TextChanged);

AjaxControlToolkit.AutoCompleteExtender CouponSearch =new AjaxControlToolkit.AutoCompleteExtender();CouponSearch.ID ="cpnAutoComplete_" + i;

CouponSearch.TargetControlID = couponTitle.ID;

CouponSearch.ServicePath ="AutoComplete.asmx";

CouponSearch.ServiceMethod ="GetCompletionList";

pnl.Controls.Add(CouponSearch);

UpdatePanel descriptionChoices =newUpdatePanel();descriptionChoices.ID ="couponChoices_" + i;

pnl.Controls.Add(descriptionChoices);

ScriptManager1.RegisterAsyncPostBackControl(couponTitle);

RadioButtonList descriptionList =newRadioButtonList();descriptionList.ID ="couponList_" + i;

descriptionChoices.ContentTemplateContainer.Controls.Add(descriptionList);

}a

}

protectedvoid couponTitle_TextChanged(object sender,EventArgs e)

{

// Code to connect to database and query results based on couponTitle entry...

string searchTerm = ((TextBox)sender).Text;findCoupon_objCmd.Parameters.Add(new SqlParameter("@dotnet.itags.org.searchTerm", searchTerm));

findCoupon_objConn.Open();

string couponNumber = ((TextBox)sender).ID.ToString().Replace("couponTitle_","");

SqlDataReader DR = findCoupon_objCmd.ExecuteReader();

RadioButtonList descriptionChoices = (RadioButtonList)defaultCoupons_pnl.FindControl("pnl_" + couponNumber).FindControl("couponChoices_" + couponNumber).FindControl("couponList_" + couponNumber);

descriptionChoices.DataSource = DR;

descriptionChoices.DataTextField ="description";

descriptionChoices.DataValueField ="allowedCouponId";

descriptionChoices.DataBind();

findCoupon_objConn.Close();

}

Hi,

You can seeCreating updatepanels at runtime? andIs it possible to add a ScriptManager and/or UpdatePanel to a MasterPage from a ContentPage dynaically? to find out how to Programmatically creating UpdatePanel.

Also seehttp://www.asp.net/ajax/documentation/live/overview/UpdatePanelOverview.aspx for the following section:

To add anUpdatePanel control to a page programmatically, you create a new instance of theUpdatePanel control. You then add controls to it by using theContentTemplateContainer property and theAdd(Control) method. Do not add controls directly to theContentTemplate property.

When anUpdatePanel control is added programmatically, only postbacks from controls in the same naming container as theUpdatePanel control can be used as triggers for the panel.

The following example shows how to programmatically add anUpdatePanel control to a page. The example adds aLabel and aButton control to the update panel by using theContentTemplateContainer property. Because theChildrenAsTriggers property istrue by default, theButton control acts as a trigger for the panel.

You cann't create Triggers Programmatically:

You can add anUpdatePanel control programmatically, but you cannot add triggers programmatically. To create trigger-like behavior, you can register a control on the page as an asynchronous postback control. You do this by calling theRegisterAsyncPostBackControl(Control) method of theScriptManager control. You can then create an event handler that runs in response to the asynchronous postback, and in the handler, call theUpdate() method of theUpdatePanel control.

Best Regards,

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

Progressbar while the updatePanel is updating or the controls are rendering in the UpdateP

Hi Guyz,

Can anybody please tell me, how can i display a progressbar on the page with Ajax, which will stay there till the time data in the Updatepanel is loading. I have a gridview in a updatepanel which displays data from the database, it has paging enabled now what i want is when user changes the page. There should be a progressbar which says Loading ... or some message like that.

I have read some posts about UpdateProgress i think its not there in Ajax Beta 1 or 2. But there is UpdatePanelAnimationExtender.
But could not find anything useful. Is there any examples for this.

Can anybody please help.

Thanks
Amit

hi amit,

did u watched scott's video i hope it will help you. open this url in media playerhttp://download.microsoft.com/download/7/8/f/78f2d61a-74c6-47b6-835c-0d1efa5524af/ScuttGu_asp_net_atlas.wmv

or onhttp://ajax.asp.net see

Video - Developing ASP.NET 2.0 Applications using AJAX

by Scott Guthrie, General Manager, .NET Development Platform

at bottom of home page.

thanks,

satish.


Thanks satish

But its really easy with the help of updateprogress control. you can put the text you want to display while the updatepanel is updating. and that's it.

It will work for you.

Anyways thanks for your help again.

Amit


no worries amit. though lucky u working on AJAX its really wonderful but its not coming my way in my companySad.

regards,

satish.


i am just using prebuilt components, not doing my own programming with ajax.
It's really easy to use man. not a big deal.

Amit

Proper documentation on new Ajax installation

A new beginner to Ajax may likely find it a bit difficult to install Ajax control toolkit controls on its toolbox and also the autocompelete extender control and e.t.c. in Microsoft.Web.Preview.dll

I found lots of documentation athttp://ajax.asp.net

You can download the controls and see samples of how to use them. Also in my blog I added links to Scott's doc and samples

Property Page for Controls?

Ok, I may just be a complete idiot, but are there extended property pages available for the controls in the toolkit at design time?

For instance, the PasswordStrength extender has a property calledTextStrengthDescriptions but as far as I can see, it is not on the properties page.

The documentation states it is initialized with this code:

<ajaxToolkit:PasswordStrength ID="PS" runat="server" TargetControlID="TextBox1"DisplayPosition="RightSide"StrengthIndicatorType="Text"PreferredPasswordLength="10"PrefixText="Strength:"TextCssClass="TextIndicator_TextBox1"MinimumNumericCharacters="0"MinimumSymbolCharacters="0"RequiresUpperAndLowerCaseCharacters="false"TextStrengthDescriptions="Very Poor;Weak;Average;Strong;Excellent"TextStrengthDescriptionStyles="cssClass1;cssClass2;cssClass3;cssClass4;cssClass5CalculationWeightings="50;15;15;20" />

But for the life of me, I cannot find this block of code anywhere - so I end up having to set the values in code. Can anyone tell me where the above init code is located or how to access the other non-displayed properties of a control in the designer?

Thanks!

Hi,

Please download the sample applicationhere, then open the PasswordStrength.aspx page, you will find it in the html source.

Providing Scroll Bars to update panel

Hi,
I am using ajax for loading different user controls . I have two main problems
1. I have a main page where i have 4 update panels . the structure is like the the following( i removed the atributes for each elemnet like id , runat etc
<table>
<tr>
<td><updatepanel><contenttemplate><uc1:ststicbar><ontenttemplate></updatepanel><td>
<td><updatepanel><contenttemplate><uc1:dynbar><ontenttemplate></updatepanel><td>
</tr>
<tr>
<td colspan=2><updatepanel><contenttemplate>content here<ontenttemplate></updatepanel></td>
</tr>
<tr>
<td colspan=2><updatepanel><contenttemplate><uc1:statusbar><contenttemplate></updatepanel><td>

</tr>
</table>

where i have two user controls on top
and one at the bottom representing toobars and ststus bar(bottom)
in the middle update panel i am loading different user controls.
my problems are.

1. I need the keep the top toolbars and bottom status bar always visible
ie when i load a user control in the midddle update panel if its height is more there should be a scroll bar
I tried with adiv tag for the content but not worked properly i find update panels emit div tag in the client.
is there any way to provide scrolling for the update panel.ie the div tag which is get emitted for the update panel.

Thanks and Regards
Jereesh

All the Style Tag works also with the table tr and td tag

apply ur style to the Table like

<table id=tbl1 style="OVERFLOW:auto;WIDTH:200px;HEIGHT:230px;">

<tr><td></td></tr>

</table>

It will sork fine iam using it.

any proble get back to me.


Hey,

Just put the update panel for which you wanna have the scrollbars, inside a panel saypanel1.

Set the height and width of the panel and set the scrollbar property of the panel as you like.

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.

Purpose of Bridging

Ok, I have the Atlas CTP, and I must say, this beats trying to just code AJAX straight up. I have gotten the hang of using the Atlas controls and can get them to do what I want on the pages I want them to perform. And if anyone on the Atlas team reads this, kudos to you guys for sharing this!

Now I have been reading somethings on Bridge files, and the .asbx extension and what not. I even read and followed thehttp://atlas.asp.net/docs/Walkthroughs/DevScenarios/bridge.aspx Mash-Up tutorial and got the application to compile and run. But still have yet to read something that says using a Bridge is good for (insert action here).

From looking at the example, it appears that it is a way to create classes that can be called from the javascript, and thus query webservices directly from the JavaScript. Is that correct, or did I miss interpret along the way?

Thanks!

I think you understand it exactly. Specifically, bridging is good when the webservice you want to call isn't on your server. Calling a webservice on another server is problematic given that modern browsers limit cross-site scripting for security reasons.

In this case, a common solution is to build a server-side proxy to make the call for you. Bridging automates much of the work involved in doing that. It also gives you an easy way to define data transformations on the results of that webservice call.

I hope that helps, and I'm glad to hear you enjoy the product!


Steve,
Thanks for the response. All of the webservices my site consumes are located on our servers and with in our domain. I guess I've never tried to consume something from another domain. Thanks for the help in the clarification, and for now, I think I'll leave bridging be, and focus more on how I can make the rest of Atlas work for me.

Thanks again!

Querities With Ajax and IE7

I have noticed many querities when using IE7 & Ajax,

For some reason, Many of the controls do not render as they used to under IE6, Unless the DOCTYPE tags are removed from each page. Which I know is not a good solution, is all that I have come up with so far to keep my site running in the mean time.

The strangest issue, for which I have seen not other posts anywhere, Is that the Collapsable Panel Extender seems to collapse and then reopen again when you try to collapse it. (Note, I also cannot seem to get the page to load with the panel collapsed) I am not sure if it has something to do with the fact that in my case the collapsable panel extender is in a user control .asax that is being called by a repeater any number of times while the page loads.

BUT, this was not an issue under IE6? - Is there anyone else experiencing this issue?

I have also a dynamic collapsible panel in my application. It works okay in IE6, but does not expand completely in IE7. It just shows 20% of the content when expanded.

Haven't found a solution yet.

Carlos

Query about ajax

Hi

can any body tell me what is ajax controls? how can i download ajax controls freely

Ajax controls are the web controls like textbox etc which uses ajax technology means can talk to the server without the entire page being posted back.

There are many Ajax toolkit available in teh market to develop this kind of controls. Two of the most popular are

Microsoft ajax toolkit ( Also known as ATLAS )

Download at :http://ajax.asp.net/

Yahoo UI control Library.

Download at :http://developer.yahoo.com/yui/

Extension to yahoo UI library :

http://www.yui-ext.com/deploy/yui-ext/docs/


Hi hemant ,

Thanks for your reply. actually i needed datepIcker calendar Control Can i download from this site freely with No licence


Hi,

For that why you need Ajax control? Calender control is available out the box for you when you use web forms. Just look into the tool box.

Question about the confirmationbuttonextender control in the ajax tool kit

Is it possible to add code to this control? I am creating a mock credit card app and am using some of the validation controls(required and regular expession). When the user clicks "buy" and the info is not entered I have a Validation Summary popup box that shows up indicating that the fields need to be filled out correctly. After clicking "OK", the confirmation box pops up asking the user "Are you sure you want to purchase this software?". How to do I change this so the confirmation popup shows up after the validation is correct?

Thanks

Hi ts2527,

Based on my understanding, I think your concern is:
1. If the input is invalid, ValidationSummary control will pop up a prompt window.
2. If the input is valid, pop up a confirm window to confirm if user really want to continue. If user click "no", nothing happen. Otherwise, do something on the server side.

By the way, pop up a confirm dialog after ValidationSummary alert window is useless (for client validation), because the page is invalid and the request will not send to the server.

Based on my test, I implement it by RegisterStartupScript instead of extending the confirmationbuttonextender control. I hope it is acceptable to you. Following is the demo code.

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
<script type="text/javascript">
function ConfirmBuy()
{
var result = confirm('Are you sure you want to purchase this software?');
if (result)
{
document.getElementById('Button2').click();
}
}
</script>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:RequiredFieldValidator ID="RequiredFieldValidator1" runat="server" ErrorMessage="RequiredFieldValidator" ControlToValidate="TextBox1"></asp:RequiredFieldValidator>
<asp:ValidationSummary ID="ValidationSummary1" runat="server" ShowMessageBox="True" />
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
</div>
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:TextBox ID="TextBox1" runat="server" Style="position: static"></asp:TextBox>
<asp:Button ID="Button1" runat="server" Style="position: static" Text="Button" OnClick="Button1_Click" />
<asp:Button ID="Button2" runat="server" OnClick="Button2_Click" Style="display:none" Text="" />
</ContentTemplate>
</asp:UpdatePanel>
<input id="Hidden1" type="hidden" runat="server" />
</form>
</body>
</html>

*********** codebehind file
protected void Button1_Click(object sender, EventArgs e)
{
ScriptManager.RegisterStartupScript(this, this.GetType(), "StartUpScript", "ConfirmBuy()", true);
}

protected void Button2_Click(object sender, EventArgs e)
{
//do something here
}

Wednesday, March 21, 2012

Question about UpdatePanel

Hi !

I have a user control with an objectDataSource and a dropDownList. These controls are inside a user control because they will be reused in some pages.

This user control has a property that returns the selectedValue of the combo.

So, in one page I add the usercontrol, another objectdatasource and a gridview. The property in the first user control is a parameter for the 2nd objectDataSource.

So, I would like to eliminate the postback when I change the 1st combo. I tried to put the 2nd ObjectDataSource and the gridview inside an UpdatePanel and create a Triger linking with the user control property, but it fails, the gridview doesn't appears.

I tried some other combinations to, and nothing works.

So : how to use a web user control to trigger an UpdatePanel ?

The UpdatePanel identifies some properties of the controls, just some. Why ? What can I do to get my property in user control recognized by UpdatePanel triggers ?

Thanks!

P.S. : Sorry by my English, I don't speak English well.

[]'s

Dennes

Hi Dennes,

Although Visual Studio doesn't show custom properties on UserControls (it's a technical limitation in VS2005), you should be able to type it in manually in source view. At runtime it should all just work.

Thanks,

Eilon


Hi !

I already tried this, but doesn't work. I think It's because I'm using a web user control, trying to make a trigger point to a custom property in web user control. I think I need to do something more, but don't know exactly what.

Just pointing the trigger to the property doesn't work.

[]'s

Dennes


Hi Dennes, can you show me a sample that reproduces this problem?

Thanks,

Eilon


Hi, Eilon !

Here, the user control :

PartialClass usrComboInherits System.Web.UI.UserControlPublic ReadOnly Property Categoria()As Integer Get If ddlCategorias.SelectedValue <>""Then Return (ddlCategorias.SelectedValue)Else Return (Nothing)End If End Get End PropertyEnd Class

<%@. Control Language="VB" AutoEventWireup="false" CodeFile="usrCombo.ascx.vb" Inherits="usrCombo" %><asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString%>" SelectCommand="SELECT [CategoryID], [CategoryName] FROM [Categories]"></asp:SqlDataSource><asp:DropDownList ID="ddlCategorias" runat="server" AutoPostBack="True" DataSourceID="SqlDataSource1" DataTextField="CategoryName" DataValueField="CategoryID"></asp:DropDownList>

The page, default.aspx :

<%@. Page Language="VB" AutoEventWireup="true" CodeFile="Default.aspx.vb" Inherits="_Default" %><%@. Register src="http://pics.10026.com/?src=usrCombo.ascx" TagName="usrCombo" TagPrefix="uc1" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head runat="server"> <title>Untitled Page</title></head><body> <form id="form1" runat="server"> <atlas:ScriptManager ID="ScriptManager1" runat="server" EnablePartialRendering="True" /> <uc1:usrCombo ID="UsrCombo1" runat="server" /> <br /> <atlas:UpdatePanel ID="UpdatePanel1" runat="server"> <ContentTemplate> <asp:SqlDataSource ID="SqlDataSource1" runat="server" ConnectionString="<%$ ConnectionStrings:NorthwindConnectionString%>" SelectCommand="SELECT [ProductID], [ProductName], [UnitPrice], [UnitsInStock] FROM [Products] WHERE ([CategoryID] = @.CategoryID)"> <SelectParameters> <asp:ControlParameter ControlID="UsrCombo1" Name="CategoryID" PropertyName="Categoria" Type="Int32" /> </SelectParameters> </asp:SqlDataSource> <asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" BackColor="LightGoldenrodYellow" BorderColor="Tan" BorderWidth="1px" CellPadding="2" DataKeyNames="ProductID" DataSourceID="SqlDataSource1" ForeColor="Black" GridLines="None"> <FooterStyle BackColor="Tan" /> <Columns> <asp:BoundField DataField="ProductID" HeaderText="ProductID" InsertVisible="False" ReadOnly="True" SortExpression="ProductID" /> <asp:BoundField DataField="ProductName" HeaderText="ProductName" SortExpression="ProductName" /> <asp:BoundField DataField="UnitPrice" HeaderText="UnitPrice" SortExpression="UnitPrice" /> <asp:BoundField DataField="UnitsInStock" HeaderText="UnitsInStock" SortExpression="UnitsInStock" /> </Columns> <SelectedRowStyle BackColor="DarkSlateBlue" ForeColor="GhostWhite" /> <PagerStyle BackColor="PaleGoldenrod" ForeColor="DarkSlateBlue" HorizontalAlign="Center" /> <HeaderStyle BackColor="Tan" Font-Bold="True" /> <AlternatingRowStyle BackColor="PaleGoldenrod" /> </asp:GridView> </ContentTemplate> <Triggers> <atlas:ControlValueTrigger ControlID="UsrCombo1" PropertyName="Categoria" /> </Triggers> </atlas:UpdatePanel> <br />   </form></body></html>

In this case, the postback still happens, the trigger is ignored. This same sample with a dropdownlist instead the user control works fine, the user control is the problem

So, I tried again, with the combo inside the UpdatePanel and no triggers. I get surprised, because it worked, but in my website It doesn't.

So, I couldn't reproduce the complete problem, just one part. My webpage is more complicated, it uses objectDataSource, call webservices and uses a customParameter (ReflectionParameter), uses a masterPage with other user controls in other parts of the complete page. One of these caused the problem with atlas, I'm still trying to discover.

My last try resulted in the following message :

Error : 'Sys.Application.findObject(...)' is null or not an object

[]'s

Dennes

Question about using AJAX to load user controls

So I'm making a pretty simple form here, and I need some help. I'll make the content of the problem abstract and just focus on what I'm trying to understand about the language.

I have two different user controls, one is form A and the other is form B. Based on a button that the user clicks (button A or button B), I want to load form A or form B. Only one form can be visible at a time.

I've created the user controls in two separate .ascx files. On the main page, I have an update panel where I placed user control A and user control B.

Currently, the page load handler in the main page sets visibility as form A visibility = false and form B visibility = true. The click handler for button A and button B will set the appropriate visibility options so that you will see form A if you click button A, and form B if you click button B. This seems to be an amateur solution to what I'm trying to do.

Here's my question that I think will lead to me a better solution:

What if I had a much larger collection of user controls? It would become unwieldly to place them all in the updatepanel, so I assume there is a way to not load them all at once. Is there way to place a reference to a 'collection' of user controls in the update panel, and then load them individually based on a user input (such as a drop down list)? Let's say there are hundreds of user controls, and I want to load only a certain one based on user input. What is the best way to do this?

Let me know if I need to clarify my question, and thank you for any answers or explanations!

You can add a PlaceHolder control inside the UpdatePanel. Then you can load the user control using Page.LoadControl method passng the appropriate path for the user control's file. Finally add the loaded user control to the PlaceHolder as a child.


Thanks for the reply! I need some clarification though.

How do I assign a place holder control inside the update panel?

I believe I understand the use of the Page.LoadControl method. Depending on the form they select, you would pass the path of that control as a string to the method.

My last question is how do I add a loaded user control to the place holder as a child?

I'm sorry if these are basic questions, but I'm new to AJAX and web programming in general, so I'm figuring this out as I go.

Thanks again for any responses.


After reading more about what I'm trying to do, I think I know how to do all but the setting of the control as a child within the update panel. Could you elaborate on that? I can't find the correct information via search engine.

I did some more research, and I figured out everything I needed to know. Thank you for pointing me in the right direction! Here is a snippet that captures what I was trying to do.

' Declare a variable named controlToLoad of type Control.
Dim ucPlaceHolderAs Control
' Call the page's LoadControl method passing it the virtual path to
' an ASP.NET UserControl (.ascx file), assigning
' the resulting control object to the ucPlaceHolder variable.
ucPlaceHolder =Me.LoadControl(sControlPath)
' Add the control object to the update panel control container
Me.UpdatePanel.ContentTemplateContainer.Controls.Add(ucPlaceHolder)


I have been tried using

upMainContent.ContentTemplateContainer.Controls.Add(Page.LoadControl(ContentControlPath));

to dynamically load a control into an update panel however, If I do anything in that control which requires a postback, the control just disappears.

Is anyone else experiencing this problem or know how to fix it?


hello.

see if this helps:

http://msmvps.com/blogs/luisabreu/archive/2007/02/15/adding-controls-to-an-updatepanel-through-code.aspx

That C# is a little confusing for me. Could someone give a VB version?

I'm actually having the same problem as one of the above posters. I can't get viewstate to persist across postbacks.

Basically, I have 3 controls. Two of the controls are composits of drop down lists, text fields, and attach, submit, and cancel buttons.

The third control is a menu that will dynamically create one of the two forms based on a button click on the menu.

I register the menu on a aspx page, and then can bring up either form based on a button click in the browser.

I need a way to load the menu again with all of the same field data entered after the user hits the attach button. I would like to keep all the code that dynamically creates forms in the menu control if possible.

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 for custom controls builder

Hi,

I build a common (non AJAX) custom control.

My control renderJavaScript with thePage.ClientScript.RegisterClientScriptResource method, so it do not work when inside an UpdatePanel.

How can we detect if the control is placed inside an UpdatePanel and use the correct method to render JavaScript ?

I found a very interesting article but it seems that it do not work with AJAX RTM bits :
http://weblogs.asp.net/leftslipper/archive/2006/11/13/HOWTO_3A00_-Write-controls-compatible-with-UpdatePanel-without-linking-to-the-ASP.NET-AJAX-DLL.aspx

How do you deal with that problem ?

The best way (I think) would be to have it happen at the server level by iterating over the control hierarchy (looking at its ancestor containers) until it gets to Page to see if any of them are of type UpdatePanel.

Question re default button inside an update panel not working

I have a page containing an update panel. Inside the update panel are two user controls: one that displays messages, and one that allows message capture.
The message-capture control looks like this:


<asp:Panel ID="PanelChatSay" runat="server" DefaultButton="ButtonSay" >
<asp:TextBox ID="TextBoxChat" runat="server" Width="90%"/>
<asp:Button ID="ButtonSay" runat="server" Text="Say" OnClick="ButtonSay_Click" />
</asp:Panel
I want the enter key to submit as if the "Say" button had been pressed. Yet when focus is in the textbox and I hit enter, nothing happens. All that seems to happen is that the text box loses focus.

Any ideas on how to fix this?

Hi,

I tried your code, the page was successfully submitted when I hit enter.

If it doesn't work for you, you may use the following script to force it.

<asp:TextBox ID="TextBox1" runat="server" Width="90%"onkeypress="if(event.keyCode == 13)document.getElementById('Button1').click();"/>

Hope this helps.


Hi AnthonySteetle,

I have read your question carefully and got a little confused. In your thread, I think you have two questions:

AnthonySteele:


I want the enter key to submit as if the "Say" button had been pressed.

My Sample:

<%@. Page Language="C#" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><script runat="server"> protected void ButtonSay_Click(object sender, EventArgs e) { this.Label1.Text = DateTime.Now.ToString(); } protected void TextBoxChat_TextChanged(object sender, EventArgs e) { this.Label1.Text = DateTime.Now.ToString(); }</script><html xmlns="http://www.w3.org/1999/xhtml"><head runat="server"> <title>Untitled Page</title></head><body> <form id="form1" runat="server"> <asp:ScriptManager ID="ScriptManager1" runat="server"> </asp:ScriptManager> <asp:UpdatePanel ID="UpdatePanel1" runat="server"> <ContentTemplate> <asp:Label ID="Label1" runat="server" Text="Label"></asp:Label> <asp:Panel ID="PanelChatSay" runat="server" DefaultButton="ButtonSay"> <asp:TextBox ID="TextBoxChat" runat="server" Width="90%" onkeyup="updateDate()" AutoPostBack="false" OnTextChanged="TextBoxChat_TextChanged"/> <asp:Button ID="ButtonSay" runat="server" Text="Say" OnClick="ButtonSay_Click"/> </asp:Panel> </ContentTemplate> </asp:UpdatePanel> <script type="text/javascript" language="javascript"> function updateDate(){ __doPostBack("<%=TextBoxChat.ClientID%>",''); } </script> </form></body></html>

AnthonySteele:


Yet when focus is in the textbox and I hit enter, nothing happens

Please confirm if your submit button is focused when the textbox is clicked. My sample seems it works fine.

Hope this helps. If I misunderstood you, please let me know.


Thank, Raymond. That does the general trick. I have it working as follows:

* remove the defaultButton declaration from the panel.
* Add the following to the page load:

protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
string enterScript = "if(event.keyCode == 13) document.getElementById('" + ButtonSay.ClientID + "').click();";
TextBoxChat.Attributes.Add("onclick", enterScript);
}
}

Now all I need to do is put input focus back in the text box after postback.