Wednesday, March 28, 2012

Changing focus when date selected in CalendarExtender control

This may fall more within the realm of general ASP.NET web development, but since it's regarding an AJAX Control Toolkit control, I thought it'd be best posted here.

I'm finding a "feature" of the calendar extender behavior to be be quite annoying. It seems that by default when a date is selected on the calendar and the selected date displays in the associated textbox, the calendar itself stays displayed and the only way I've found to get rid of it is to click anywhere outside the calendar itself. You can't tab out of it to the next textbox, Enter won't get rid of it, etc.

I'm sure there's a way to have the calendar collapse when the date is changed, but I just don't know how - could someone provide a way to do this?

Here's the code for my calendarextender:

<asp:TemplateField HeaderText="Date"><ItemTemplate><asp:Label ID="lblWeatherDate" runat="server" Text='<%# Bind("WeatherDate", "{0:dd-mm-yyyy}")%>' /></ItemTemplate><EditItemTemplate><%-- OnTextChanged="txtWeatherDate_OnTextChanged" --%><asp:TextBox ID="txtWeatherDate" Text='<%# Bind("WeatherDate")%>' runat="server"TabIndex="0" Width="80px" Font-Size="10px" /><ajaxToolkit:MaskedEditExtender ID="editExtWeatherDate" runat="server" TargetControlID="txtWeatherDate" Mask="99/99/9999" MaskType="Date" MessageValidatorTip="True" OnFocusCssClass="MaskedEditFocus" OnInvalidCssClass="MaskedEditError" ErrorTooltipEnabled="True" /><ajaxToolkit:MaskedEditValidator ID="editValidatorWeatherDate" runat="server" ControlExtender="editExtWeatherDate" ControlToValidate="txtWeatherDate" IsValidEmpty="True" InvalidValueMessage="Invalid entry. Select a date from the calendar or enter the format "mm\dd\yyyy"" Display="Dynamic" InvalidValueBlurredMessage="Error" /><ajaxToolkit:CalendarExtender ID="calExtWeatherDate" runat="server" Enabled="True" TargetControlID="txtWeatherDate" Format="MM/dd/yyyy" /></EditItemTemplate></asp:TemplateField>

As you can see I tried messing with the OnTextChanged of the textbox and started up with this code:

Sub txtWeatherDate_TextChanged(ByVal senderAs Object,ByVal eAs EventArgs)Handles txtWeatherDate.TextChangedDim txtWeatherDateAs TextBox =Me.gvWeather.FindControl("txtWeatherDate")txtWeatherDate.End Sub

But I couldn't figure out where to go with that. I was looking for something to do with changing the focus of the textbox, but couldn't figure that out.

Any help would be greatly appreciated.

Thanks!

this is in c# but this is how i get the calendar extender to close on date click

to close the calendar onClick i set this up in the code behind

//Hide the calendarprotected override void OnLoad(EventArgs e) { Page.ClientScript.RegisterClientScriptBlock(this.GetType(),"hideCalendar", @."function hideCalendar(cb) { cb.hide(); }",true);base.OnLoad(e); }

and this is what the asp code looks like

 <cc1:CalendarExtender ID="CalendarExtender1" runat="server" TargetControlID="txtDate" OnClientDateSelectionChanged='hideCalendar'>

Hey, keyboardcowboy

Thanks for the code. It was pretty much a copy-paste thing. The C# converted nicely in a code converter. After selecting the date, the calendar disappears, as it should.

However, the oddest thing is happening now: The date displays in the date label as "dd-00-yyyy". I.e. the proper date number,two zeros for the month, then the proper year. This is regardless of what formatting I use for either the extender or the textbox (I was usingFormat="MM/dd/yyyy" in the extender). The date in the sql table it's coming from is correct and the date can be changed and saved (this is in a gridview) properly and it is even displayed properly when the textbox is showing while the gridview is in edit mode. It's just messed up in the label.

I was using the following for the bound text value for the date label:Text='<%# Bind("WeatherDate", "{0:dd-mm-yyyy}")%>'.When I remove the formatting string the date displays properly, but with the time as well. I can't get the date formatted to mm-dd-yyyy now!

Any thoughts?

Thanks


Okay, I caught one thing I was doing wrong: I was using two different formats: dd-mm-yyyy in the label and mm-dd-yyyy in the textbox.

But unfortunately, getting those two to the same format didn't fix the display problem. It's still displaying the month as two zeros (00). And that's regardless of whether I set the format as dd-mm-yyyy or mm-dd-yyyy.

Weird...


weird. maybe if that format string you are trying doesnt work you can try this .ToShortDateString(); that will display a date but without the time. it works in c# in sure it does in vb also so try this (not sure if it will work because i think casting types is different in vb)

Text='<% # ((DateTime)Bind("WeatherDate")).ToShortDateString()%>'


Yeah - I tried just putting it in my label, but got a build error, saying "DateTime" is a type and cannot be used as an expression. I don't know quite enough to know how to change it to work for my VB code.


Okay - found out CDate is used for casting dates. But I can't find quite the right syntax. I've tried: Text='<%# Bind(CDate("WeatherDate")).ToShortDateString() %>' , and Text='<%# CDate(Bind("WeatherDate")).ToShortDateString() %>' and even Text='<%# Bind((CDate("WeatherDate")).ToShortDateString()) %>' so far, but got build errors saying the Bind was not well formed.

Anyone know what the correct syntax would be in this case?

Thanks


I would make a new topic for the problem with your date and give it a title about the date. Some people will know how to do this in vb but will not check this post because it is about calendar stuff :P


Good idea. Will do. Thanks for your help - you got me further than I was an hour ago!

Regards

Changing dynamically a user control within an UpdatePanel

I have a page that (using ajax), will dynamically route someone through a bunch of survey questions. Each survey page is written as a user control as each page needs to have a lot of flexibility, etc to visually add/edit HTML, blah, blah, but that's not the problem. I'm having a problem with loading the question too late in the page life cycle, so our respondent will see the following...

Introduction, Q1 (where they answer), Q1 again (as their answers aren't remembered), Q2 (Q1 answers were remembered this time), Q2 (again, cause Q2 answers weren't remembered first time again)... and so on, etc.

I know what the problem is, but I'm drawing a blank on how I can execute what I want properly. I've attached the code for my controlling page below. Thank you for any advice anyone can offer!!!

<%@dotnet.itags.org. Page Language="C#" MasterPageFile="~/survey.master" Title="Surveys" %>
<%@dotnet.itags.org. Import Namespace="SurveyWebControls" %><script runat="server">
const string SurveyStart ="SurveyStart";

SurveyPageBase currentSurveyPage;

protected void Page_PreInit(object sender, EventArgs e)
{
Page.Theme ="SurveyDefault";
}

protected void Page_Load(object sender, EventArgs e)
{
lblErrorMessage.Text ="";

if (txtCurrentSurveyPage.Value =="")
LoadSurveyPage(SurveyStart);
else LoadSurveyPage(txtCurrentSurveyPage.Value); }protected void btnNext_Click(object sender, ImageClickEventArgs e)
{
if (currentSurveyPage.Validated)
LoadSurveyPage(currentSurveyPage.NextPage);
else lblErrorMessage.Text = currentSurveyPage.ErrorMessage; }private void LoadSurveyPage(string QId)
{
Survey.Controls.Clear();
currentSurveyPage = (SurveyPageBase)LoadControl(QId +".ascx");
Survey.Controls.Add(currentSurveyPage);
txtCurrentSurveyPage.Value = currentSurveyPage.QId;
btnNext.Visible = currentSurveyPage.ShowNext;
}

</script
<asp:Content ID="SurveyBody" ContentPlaceHolderID="SurveyBody" Runat="Server">
<asp:UpdatePanel ID="SurveyUpdatePanel" runat="server">
<ContentTemplate>
<asp:HiddenField runat="server" ID="txtCurrentSurveyPage" />
<asp:Label runat="server" ID="lblErrorMessage" SkinID="ErrorMessage" />
<asp:PlaceHolder ID="Survey" runat="server" />
<br /><br />
<asp:ImageButton ID="btnNext" SkinID="NextButton" runat="server" OnClick="btnNext_Click" />
</ContentTemplate>
</asp:UpdatePanel>
</asp:Content>
Try to use the template of asp:Wizard to load?user?controls?dynamically.?Try?to?take?a?look?at?the?following?materials?for?details.
http://msdn2.microsoft.com/en-us/library/fs0za4w6(VS.80).aspx
http://aspnet.4guysfromrolla.com/articles/061406-1.aspx
http://support.microsoft.com/kb/180405
http://weblogs.asp.net/sushilasb/archive/2004/03/31/104939.aspx
http://aspalliance.com/766_Working_with_the_Wizard_Control_Using_Visual_Studio_2005

Wish the above can help you.
I had thought of that, but it would still have to be dynamic. Sometimes there are literally hundreds of pages where someone might only go through 5 of them, based on how they answer previous questions.

Changing CSS or STYLE of TabContainer and TabPanes

Hi to all...

I have a question and i need answersSmile

I have a AJAX tabContainer witch add tabPanes dynamicly, but now i want to change the style or CSS of her, but i cant...

Can anyone help me!?

Hi Rikardo,

Here is a sample which indicates how to add css to the newly added Panel. If it is not you really want , please feel free to let me know with more explanations.

TabPanel myNewTab = new TabPanel();
myNewTab.ID = "TabPanel3";
myNewTab.HeaderText = "TabPanel3";
myNewTab.CssClass ="the tab css style";
Button myButton = new Button();
myButton.ID = "myButton";
myNewTab.Controls.Add(myButton);
this.TabContainer1.Tabs.Add(myNewTab);

I hope this help.

Best regards,

Jonathan


Jonathan Shen – MSFT:

Hi Rikardo,

Here is a sample which indicates how to add css to the newly added Panel. If it is not you really want , please feel free to let me know with more explanations.

TabPanel myNewTab = new TabPanel();
myNewTab.ID = "TabPanel3";
myNewTab.HeaderText = "TabPanel3";
myNewTab.CssClass ="the tab css style";
Button myButton = new Button();
myButton.ID = "myButton";
myNewTab.Controls.Add(myButton);
this.TabContainer1.Tabs.Add(myNewTab);

I hope this help.

Best regards,

Jonathan

In addition to the above

Just be careful when you are naming the css classes! There seems to be a bug in the tab panes extender, where strange things happen if you change the defaults css names.

follow this linkhttp://www.codeplex.com/AtlasControlToolkit/WorkItem/View.aspx?WorkItemId=11238 to Codeplex for comments and workarounds for this bug.

Good luck

changing button values on a tab

I have a AsP.net,VB.net app using tabs and I have two buttons at the bottom of the page that i want to change everytime the user goes to the next tab.

IE: btnBack and btnProceed, when you go to page two I want to change the image URL to be imageButtonBackToPage1 and imageButtonProceedToPage2 and so on, hope you get the idea.

Anyways, there are two ways for the user to go through the pages, 1 is using the tabs and 2 is using the buttons.

when the user uses the buttons i am able to change the imageurl easily but when the user uses the tabs nothing fires so I want to change the imageURl for the new page and saw that OnClientActiveTabChanged can find the active tab but I need a good example (of javascdript and HTML) of how to use this because I want to find out the active tabe and change the button images according to that.

Does anyone have good examples of how to do this? thanks.

Hi!

You could fire a post-back on Tab click using the following function, and setting the OnClientActiveTabChanged event toOnClientActiveTabChanged="ActiveTabChanged"

<script type="text/javascript">
function ActiveTabChanged(sender, e)
{
__doPostBack('<%= TabContainer1.ClientID%>', sender.get_activeTab().get_headerText());
}
</script>

Then, on code behind, use the TabContainer_ActiveTabChanged to change any values for the buttons.

Hope this helps,


thanks, what is the syntax for aclling ActiveTabChanged in the aspx page (what do you pass for sender and e?

Also, I am doing this with Ajax so I dont think the postback will work.


Hi,

Just scroll down the events drop-down list on VS 2005 and select ActiveIndexChanged on the TabContainer Control, then use the ActiveIndex or the ActivePanel properties to apply any code you need.
On server side you are not catching the javascript function, just using it as a trigger.

Why the post-back wouldn't work because AJAX? It's just firing an event which otherwise doesn't get fired by default. You can put your TabContainer inside an UpdatePanel and set the TabContainer_ActiveIndexChanged event as a trigger and you won't notice the difference. I'm using this approach and it works perfectly.


Thanks, this helps greatly, i am still learning Ajax. if you can post any sample code that would be great. thanks for your help, this saved me a lot of time.

Hi! You're welcome!

Just post your code and let us know where you are stuck, but basically is something like:

Protected Sub TabContainer1_ActiveTabChanged(ByVal sender As Object, ByVal e As System.EventArgs) Handles TabContainer1.ActiveTabChanged
If TabContainer1.ActiveTabIndex = 0 Then
Button1.ImageUrl = "YourPic"
ElseIf TabContainer1.ActiveTabIndex = 1 Then
Button2.ImageUrl = "YourPic"
End If
End Sub


thanks, almost there, one thing I noticed is that I had to set AutoPostBack=true for the TabContainer and now its capturing the event in the vb.net code. I thought I would be done with this task now but a funny thing is when I switch from tab to tab now its not changing the button images (i have code just like you wrote in your last post there) so I am really puzzled now, please let me know if any of you have any ideas. thanks.


Hi!

That's not a problem, just put your buttons inside UpdatePanels and call UpdatePanel.Update() from the TabContainer.ActiveIndexChanged event, or set the button's UpdatePanel triggers accordingly.


Thats it! thanks much, it works great now!


Hi! Well, I'm glad it helped!

Could you please mark the post answered to close the thread?

Cheers,

Changing Background Color Of Text box ?

Hello,

I need something as Follow..

I am having one Data Entry form. Here I have many controls (All type of controls like Textbox, Dropdownlis, Checkboxex esc...)

Now when user focus any text box then its Background color should change. Can we do it using ATLAS, xmlScript, Javascript...

one more problem is that I am having nearly 20 Text boxes on my page so which way I can get this functionality using less efforts...

Atlas is a really "heavy" way to do this. I'd just do it with Javascript and CSS.

<style type="text/css">

.normal

{

background-color:inherit;

}

.focus

{

background-color:yellow;

}

</style>

<script type="text/Javascript">

function changeTextbox(control){

var x = document.getElementByID(control);

if (x.classname == "normal"){

x.classname = "focus";

}

else {

x.classname = "normal")

}

}

</script>


Nice..

But the Parameter CONTROL in function... comes from where ?

Means from where we can pass it ?


You pass the control paramater when you call the function from the onFocus even of your textbox. It would be just as easy to capture the sender though, and get the calling object of the function, so it didnt need a paramater.
You don't need atlas or ajax at all, some javascript and dhtml will do:
foreach (Control ctrlin Form.Controls){if (ctrl.GetType() ==typeof(TextBox)) { ((TextBox)ctrl).Attributes.Add("onfocus","javascript:this.style.backgroundColor='red'"); ((TextBox)ctrl).Attributes.Add("onblur","javascript:this.style.backgroundColor='white'"); }}

Changing Background color of grid row when row checkbox selected

What option should I choose:

1) Write java script for this

2) Write server code and have grid in UpdatePanel

?

Not clear what the best guidline would be. I am already using update panel for that grid.

I guess the best solution should be if I have defined this background color in CSS.. I guess I could use java script to change the class name dynamicly and have that class defined in CSS. Not sure how to do it...


Here's some sample code I use in my custom ajaxed gridview control...

May or not work for you but should give you some idea..

 protectedvirtualvoid GridView_RowDataBound(Object s,GridViewRowEventArgs e)

{

if (e.Row.RowType ==DataControlRowType.DataRow )

{

//Note: Here is where we change the button submit so that

//our IPostBackHandler can properly handle AJAX requests.

int editID = (int)DataBinder.Eval(e.Row.DataItem,"id");

e.Row.Attributes.Add("onMouseOver","SetNewColor(this);");

e.Row.Attributes.Add("onMouseOut","SetOldColor(this);");

e.Row.Attributes.Add("onDblClick", Page.ClientScript.GetPostBackEventReference(this, e.Row.RowIndex.ToString()));

e.Row.Attributes.Add("onKeyDown","if( event.keyCode == 13 ) " + Page.ClientScript.GetPostBackEventReference(this,"KEYDOWN" +"$" + e.Row.DataItemIndex.ToString()));

Here is the code for adding it to the script manager on the prerender() phase

protected override void OnPreRender(EventArgs e) {string script = @." var _oldColor; function SetNewColor(source) { _oldColor = source.style.backgroundColor; source.style.backgroundColor = '#00ff00';} function SetOldColor(source) { source.style.backgroundColor = _oldColor; }"; ScriptManager.RegisterClientScriptBlock(this,typeof(Page),"ToggleScript", script,true);

Here is the aspx / ascx .Net code to use if you do not wanna do the PreRender event...

<script language="javascript" type="text/javascript"> var _oldColor; function SetNewColor(source) { _oldColor = source.style.backgroundColor; source.style.backgroundColor = '#00ff00';} function SetOldColor(source) { source.style.backgroundColor = _oldColor; } </script>

That should set you on the right direction....at least...


I have tried your aproach, I have created very similar code, but in my code I want to change ackground colour when the checkbox is chcked... It changes the color, but than it does not reverse it back to the old color... Any idea?

function highLight(CheckBoxObj){

var _oldColor;

if (CheckBoxObj.checked ==true) {

_oldColor = CheckBoxObj.parentElement.parentElement.style.backgroundColor;

CheckBoxObj.parentElement.parentElement.style.backgroundColor ='#D6DEEC';

//'#88AAFF';

}

else

{

CheckBoxObj.parentElement.parentElement.style.backgroundColor = _oldColor;

}


OK, I almost figured this out. My _OldColor variable needs to be global, outside of the function of course. OK, it seems to be working for one chcekbox at the time, but when multiple checkboxes are selected it doe not work. My guess would be I need to put the saved value to the array, but not sure how to do it...

var _oldColor;

function highLight(CheckBoxObj){

if (CheckBoxObj.checked ==true) {

_oldColor = CheckBoxObj.parentElement.parentElement.style.backgroundColor;

CheckBoxObj.parentElement.parentElement.style.backgroundColor ='#D6DEEC';

//'#88AAFF';

}

else

{

CheckBoxObj.parentElement.parentElement.style.backgroundColor = _oldColor;

}


In fact I suspect you may have the same problem happening in yourcode as you also do not put it (old color) into an array...

I was merely interested in just showing it highlighted for editing not necessarily for the checkboxes although that would be a nice feature to incorporate...

here some SAMPLE CODE to bite your teeth into - its out of the ajaxtoolkit... shows how to at least work with the arrays:

disableTab :function()

var i = 0;

var tagElements;

var tagElementsInPopUp =new Array();

this._saveTabIndexes.clear();

//Save all popup's tag in tagElementsInPopUp

for (var j = 0; j <this._tagWithTabIndex.length; j++) {

tagElements =this._foregroundElement.getElementsByTagName(this._tagWithTabIndex[j]);

for (var k = 0 ; k < tagElements.length; k++) {

tagElementsInPopUp[i] = tagElements[k];

i++;

}

}

Its from the ModalBehavior.js if you need to examine it a bit more...


Also some of the checkboxes can be initially checked as I keep track of those checked if user changes the pages... I used some code for this, I found on the web...

Thank you very much, the problem is how to get an index of the curren checkbox in the function (I am new to js):

function highLight(CheckBoxObj){

//var theBox=(spanChk.type=="checkbox")?spanChk:spanChk.children.item[0];

//xState=theBox.checked;

//elm=theBox.form.elements;

//for(i=0;i<elm.length;i++)

//if(elm[i].type=="checkbox" && elm[i].id!=theBox.id)

//{

////elm[i].click();

//if(elm[i].checked!=xState)

//elm[i].click();

if (CheckBoxObj.checked ==true) {

_oldColor = CheckBoxObj.parentElement.parentElement.style.backgroundColor;

CheckBoxObj.parentElement.parentElement.style.backgroundColor ='#D6DEEC';

//'#88AAFF';

}

else

{

CheckBoxObj.parentElement.parentElement.style.backgroundColor = _oldColor;

}

This is my checkbox declaration (onclick works somehow, even not recognized by VS editor...):

<ItemTemplate>

<asp:CheckBoxid="chkActive"onclick="javascript:highLight(this);"runat="server"></asp:CheckBox>

</ItemTemplate>

changes to adding ScriptReference?

Greetings! I have a javascript file that does some rounded corners on my page called rounded.js. In Beta1 I declared it like this

<asp:ScriptManager ID="ScriptManager1" runat="server"> <Scripts> <asp:ScriptReference Path="~\rounded.js" /> </Scripts></asp:ScriptManager>

This is inside my Master Page. After the content place holders, at the end of the master page I have this.

<script type="text/javascript"> Rounded('header',6,6); Rounded('navigation',6,6); Rounded('content',10,10); Rounded('navigationright',6,6); Rounded('footer', 6, 6); </script>

It worked great with Beta1 but doesn't in Beta2. There are no rounded corners, and the javascript error reads:

Sys.ScriptLoadFailedException: The script 'rounded.js' could not be loaded or does not contain the Sys.Application.notifyScriptLoaded() callback.

Now, if I navigate with the back and forward buttons to pages inside my app, I still get the error, but the script does load somehow, because the rounded corners are there.

Please help!

Check out the release notes for the ASP.NET AJAX Extenstions (C:\Program Files\Microsoft ASP.NET\ASP.NET 2.0 AJAX Extensions\v1.0.61025\ReleaseNotes.txt)...

Under "4.3: Client Framework" you will see some notes about "* Script loading improvements". Relevant to your situation: "Component developers and page developers creating file-based script libraries that are registered with the ScriptManager control should include a JavaScript code snippet that indicates that the library has been downloaded by the client. Although this is not required in all browsers, Safari requires this to be able to dynamically load scripts."

Try adding this line to the very end of your 'rounded.js' file:

if(typeof(Sys) !='undefined') Sys.Application.notifyScriptLoaded();

Thanks,
Kyle


Is the CTP libraries also need this change?

I use this code to reference CTP libraries:

1<asp:ScriptManager ID="ScriptManager1" runat="server" >2<Scripts>3<asp:ScriptReference Path="~/PreviewDragDrop.js" />4<asp:ScriptReference Path="~/PreviewGlitz.js" />5<asp:ScriptReference Path="~/PreviewScript.js" />6</Scripts>7</asp:ScriptManager>
is it right? I copied these files to my site's root directory.
and I also got the "script could not loaded" exception while running...

hello.

well, i think the value added bits don't notify the sys.application object on completion of the load. so, you can add that line to the files or you can add them to the page through the <script> element.


hey all

im having the same problem now ive upgraded :-(

The solution was to add the following line:

if(typeof(Sys) !='undefined') Sys.Application.notifyScriptLoaded();

Im still getting the same error being thrown though :-( My JS file looks like this:

function

test()
{
alert("function called");
}
if(typeof(Sys) !='undefined') Sys.Application.notifyScriptLoaded();

and i call the script like this:

<

Scripts>
<asp:ScriptReferencePath="JScipt.js"/>
</Scripts>

What am i doing wrong??

Cheers Will


hello,

make sure IE is not caching the js file.


hey - thanks for the quick reply!

Yeh i just tried clearing out all the IE cache, but its still moaning :-(

What else could i be doing wrong?


hello.try debugging the page and make sure that the call to notifyscriptloaded is being made.

ok im getting somewhere!

i tried changing the script path on my test project to an absolute path

before: Path="JScript.js"

after: Path="http://localhost:2303/AjaxControlToolkitWebSite1/JScript2.js"

all works fine! this is not summet i want to do, so why is not looking in the wrong place?

Cheers for ya help dude

Will


hello.

i've been having some problems with the internal server, ie, i'm having several issues with the caching of files when i use the internal server.


I am having the exact same problem with the internal server caching files...did you figure out a good work around?

Thanks, Greg Benoit


hello.

wll, not really. i've started using IIS :)


What are the steps for converting an existing file based project to using IIS?? I tried and almost got it working, but when I went to login using my login control and the aspnetdb the login control reported back that my login credentials were incorrect??

Thanks, Greg

Changes from the Ajax RC to v1.0

Is there a changelog somewhere, or something that shows what changes (if any) were made between the Release Candidate and version 1.0?

Specifically, I'm wondering if v1.0 has support for Web Parts and/or the TreeView Control? But I'd also like to see any other (significant changes between the 2 versions).

Thanks ...

here is white paper

http://ajax.asp.net/documentation/AspNet_AJAX_CTP_to_RC_Whitepaper.aspx

Changes are applied several times

Hello,

Here is the situation: a control that isoutside the UpdatePanel passes its changes to the server through a hidden field. A button that isinside the UpdatePanel causes partial posts back. When a full post back occurs the changes that are made to the control are applied as many times as the partial post back was triggered.

Looks like the update panel actually grabbing all of the hidden fields on the page and brings them to the server (which sounds ok) and modified ViewState is fed back to the client (that should not happen, I think) and then reused for next posts.

Is there a way to around that?

Thanks!

Alex

i dont know if i got you correctly .....but why dont you destroy the value of the hidden filed once your work is done...this way it wont go back

Changed control prefix doesnt apply when dragging control from toolbox

Hello,

due to problems with Intellisense not recognizing the new ajax controls such as updatepanel and scriptmanager I tried to give them a different prefix. I thought ajax would be nice instead of asp, so I specified this in my web.config

<add tagPrefix="ajax" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
However, when I drag 'n drop an Ajax control from the toolbox it will still get the asp prefix. Now I've done some custom control development, so I know you can give a control an attribute called ToolboxData where you can use a placeholder for the actual prefix. So did the Ajax developers not use this, or do I need to do something else to get my new prefix when I select a control from the toolbox?

hello.

well, I'm thinking that they've only used the tagprefixattribute to set the default attribute of the controls...


Yes, but the design surface and intellisense will normally use the prefix that is specified in the web.config. However, I think I may have found a bug. It seems there might be a problem is there's a newline character in the assembly attribute. Maybe you could try this out to confirm this?

Thanks!

Change WatermarkText in VB code behind

I would like to be able to change the WatermarkText in my VB.NET code.

<atlasToolkit:TextBoxWatermarkExtender ID="txtWMEAddress1" runat="server">
<atlasToolkit:TextBoxWatermarkProperties TargetControlID="txtAddress1" WatermarkText="test" WatermarkCssClass="WaterMark" />
</atlasToolkit:TextBoxWatermarkExtender>

Your help is appreciated.

Thank you

it's really as easy as saying:

txtWMEAddress1.WatermarkText =

"Text from code behind"


I tried that before I put up the original posting.

There is no direct property of a TextBoxWatermarkExtender called"WatermarkText".

There is a separate tag called TextBoxWatermarkProperties, but does not have an ID or a runat to access it from the code behind.

The syntax should be (I think) txtWMEFirstName.<access TextBoxWatermarkProperties>.WatermarkText = "My text"

<atlasToolkit:TextBoxWatermarkExtender ID="txtWMEFirstName" runat="server">
<atlasToolkit:TextBoxWatermarkProperties TargetControlID="txtFirstName" WatermarkText="First Name" WatermarkCssClass="WaterMark" />
</atlasToolkit:TextBoxWatermarkExtender>

How should I be doing this?

Thank you very much.


Your code seem to be using pre-beta code of ASP.NET Ajax. Is there any reason why you are still using that version. In the current version of ASP.NET Ajax there is no separate TextBoxWatermarkProperties, instead TextBoxWatermarkExtender has the WaterMarkText property.

Change visible accordion panel client side

How can I change which accordion panel is visible using javascript?

Try this ..

function OpenPane(paneIndex) {var accHost = $get(<AccordionID>).AccordionBehavior ;accHost.set_SelectedIndex( paneIndex );}The "AccordionBehavior" lets you access the methods as you would do with a BehaviorID.
Please mark my reply as an answer if this solves the issue

Thanks for the response. I added alerts to the javascript as shown below, because nothing was happening. The first alert works, but the second alert is never displayed.

function

OpenPane(paneIndex)

{

alert(paneIndex);

var accHost = $get('Accordion1').AccordionBehavior;

alert(accHost);

accHost.set_SelectedIndex( paneIndex );

}

What's wrong?


Hi,

If you dont get the second alert , you should have an error at the line $get('Accordion1').AccordionBehavior.

Can you check if $get('Accordion1') is a valid object .

change the code to be

functionOpenPane(paneIndex)

{

alert(paneIndex);

var accord = $get('Accordion1');

var accHost ;

if( accord != null)

{

accHost = accord.AccordionBehavior;

}

alert( accord );

alert(accHost);

accHost.set_SelectedIndex( paneIndex );

}

and also , what is the ID of the Accordion You are using , "Accordion1" ?


That code should work. If you're not getting to the second alert(), my guess is that "$get('Accordion1')" is returning null. Are you sure you have the correct ID of your Accordion?

If "Accordion1" is the server ID, you probably want: $get('<%= Accordion1.ClientID %>') in case the client ID is different (because it's inside a naming container, for example).


Excellent. Between Phanatic and Steve it is now working properly. Thanks very much, both of you.

Hi,
Need your help.
I am using the Accordion Panel. I have tried your code, but unfortunately couldnt get it to work.

I am getting error in accessing the property AccordionBehavior.

"accHost = accord.AccordionBehavior;"
accHostalways contain undefined value.

any help would be apprecitated..

Thanks in advance.

--Saurabh

.

change values dependes on menus

hi, please see this page :

http://www.microsoft.com/en/us/default.aspx

in this page if i keep my mouse on menus contents are changing. like this i want to do. so what i have todo?please hosw some example link to achieve my need please

I would start with the Hover Menu, link to video below, which would allow you to handle essentially popping up the additional context.

http://www.asp.net/learn/videos/view.aspx?tabid=63&id=93


please can any one give some helpful link which relates my thread please


The last guy did give you a helpful link that relates to your thread. Here's a link to samples for that same thing:http://ajax.asp.net/ajaxtoolkit/HoverMenu/HoverMenu.aspx

The only difference between the hovermenu in the video and the one at the link you provided is content and style.

Change to invokeViaServer method

Why was the old ModalPopupBehavior.invokeViaServer method changed to remove the section that deals with the partial page update? I was using that method, and now that I'm migrating to the new code base .. I'm just a little confused.

Also, has anyone explained publically why getDescriptors is now gone?

getDescriptors is gone because the ASP.NET AJAX Beta (referred to as "Core") no longer supports TypeDescriptor. That stuff was mostly there to support XML Script, so it was no longer needed.

For the invokeViaServer stuff, much of that code shouldn't be needed anymore. I didn't do the work on that component so I'm not completely sure (David did the work and he's out of the office this week) if it's critical or not. Try it as is and report back if it's not doing the right thing. The way that components get called after a partial update has changed, it may address this scenario.


Oh, so .. was XML Script scraped? So many breaking changes for developers .. ^_^ Yea, I was using the invokeViaServer method for a few controls of mine, and was curious about the change while I was trying to migrate from the last CTP to the Beta. With so many changes, it's hard to tell. You can't see the list of check-in notes *easily* on the Codeplex site, which is where some of the documentation is going.

Even if you could, it probably wouldn't help. The number of checkins associated with the migration was well into the hundreds I'm sure (basically 3-6 people working 12+ hours a day for 2.5 weeks...) so it would be hard to pick things out.

Your better bet is to check out the migration materials onhttp://ajax.asp.net and my blog entry(s) on the subject athttp://blogs.msdn.com/sburke.

Change TimerControl Interval property without postback

Hi,

I have a "Live monitor" scenario, where data in UpdatePanel is being updated on TimerControl tick.

I want to give user an ability to change interval. It works fine, but postback is needed to do so.

Any way to do it without a postback?

(I'm new to atlas, so please excuse me if it's obvious.)

hello.

well, if you're ready to build your own timer, then it's possible to do that in the client side. currently, the problem is that the timercontrol generates a client behavior but doesn't generateou an id. due to this, you cannot get a reference to the behavior in the client side and do need to do a postback to refresh that interval.

Change Themes using Ajax

Hi,

I am changing themes dynamically when i am clicking image button. i write a code to change the theme at Page_PreInit().

I need to reload the page to take effect. so i used response.redirect(SamePage.aspx). hope response.redirect is not supported on update panel.

i need to change themes using Ajax( without postback).

Thanks in Advance.

I don't think you can change the theme directly using ajax; but what you can do is change the href on your link tag(s) to give you new stylesheets.


Hi,

I think you dont need to Redirect to the same page to change the theme.

Just put

if(Page.IsPostBack)

GridView1.SkinID ="newskinID" in the Page.PreInit event.

Thanks,

Regards

Aruna


Hi,

My previous reply was to change the Skin of a particular control.

If you want to change the theme u can put this code

if (Page.IsPostBack)

this.Page.Theme ="NewSkinFile"

in the Page.PreInit Event Handler

Regards,

Aruna


Aruna,

Thanks for your response.

This is my code.

protectedvoid Page_PreInit(object sender,EventArgs e)

{

if (Request.Cookies["theme"] !=null)

{

this.Theme = Request.Cookies["theme"].Value.ToString();

}

else

{

this.Theme ="Black";

}

}

protectedvoid ImgGreen_Click(object sender,ImageClickEventArgs e)

{

HttpCookie cook=newHttpCookie("theme");

cook.Value=((ImageButton)sender).CommandName;

cook.Expires =DateTime.MaxValue;

Response.AppendCookie(cook);

string[] path = Request.Path.Split(char.Parse("/"));

Response.Redirect(path[path.Length-1].ToString() );

}

when i click image button, i stored theme name in a cookie. based on a cookie i am loading theme.

Page_PreInit() method never fire after image button click until the page reload ( Page_PreInit() will fire first).

so, i redirected to same page.

It is immediately taking theme.

Actually my problem is the page is get postback even i am using update panel.

you got my point.


Paul,

Thanks.

I referred two sites. Live.com and msn india. they are changing page themes without postback. so, i tried.

If you will get resource, post here.

once again thanks paul.


Hi Nanda,

Have u set the commandName of Image Button to the name of the Theme, as you mentioned cook.Value=((ImageButton)sender).CommandName you are trying to put the name of Command in the cookie.

Regards,

Aruna


Aruna,

I am using 4 themes in my project. so, i put 4 imagebutton in my page. all 4 buttons are sharing one methodImgGreen_Click(). so, based on the command name, i am trapping which button is clicking by the user ( i assigned theme name as command name for all four button.)

Thanks.


As I said before, you can't do it the way you're trying to do it. The ASP.Net 'theme' is a pretty rigid thing, and it's set during the Init cycle, which does not fire if you're using and updatepanel (see the documentation on page lifecycle).

If you want to change the look and feel of your site without postback, the way to do it is to build a CSS-based design, and then swap stylesheets from the client.


Dear,

You have redirected to the same page that's y ur page is posted back.

The major problem in your code is PreInit Fires before the button click event, so u cant modify the theme on click of the button by using this code as preinit fires first so it takes the theme of previous click.


Hi,

Hope u have solved ur problem.

If not then let me know I have a solution of ur problem.

Regards,

Aruna


Is that it ? Is CSS-based design the only way to achieve themes without postbacks ?

Aruna, do you have an alternate solution ?

Thanks

Jai

change the visable of page controls

in my UserControl,there are 3 controls, DropDownList1,DropDownList2,TextBox1

DropDownList1,DropDownList2 are for the ajaxToolkit:CascadingDropDown

TextBox1.Visible=false;

but now when DropDownList1.SelectedItem.Text=="other",I want to change DropDownList2.Visible=false;TextBox1.Visible=true;

I make it via AJAX

<asp:ScriptManager ID="ScriptManager1" runat="server">
<Services>
<asp:ServiceReference Path="TypeService.asmx" />
</Services>
<Scripts>
<asp:ScriptReference Assembly="Microsoft.Web.Preview" Name="PreviewScript.js" />
</Scripts>
</asp:ScriptManager>

<script language="javascript">

...

Type_service.CheckOther(DropDownList1.value);

....

</script>

but the problem is now

how my TypeService.cs call the function in the CascadingDropDown.ascx.cs

Hi,shootarrow

I'm afraid that you cann't do this in that way.

You can do this at the client side!

Try this:

Default.aspx:

<%@. Page Language="C#" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>

<script type="text/javascript">
// This function calls the Web Service method.
function EchoUserInput()
{
//Do something you want to do, e.g.delay the script execution
var echoElem = document.getElementById("EnteredValue");
WebService.HelloWorld(echoElem.value,SucceededCallback);
}
// This is the callback function that processes the Web Service return value.
function SucceededCallback(result)
{
var RsltElem = document.getElementById("Results");
RsltElem.innerHTML = result;
// Change the delay of the script execution back.
}
</script>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server">
<Services>
<asp:ServiceReference Path="WebService.asmx" />
</Services>
</asp:ScriptManager>
<div>
<h2>
Simple Web Service</h2>
<p>
Calling a simple service that echoes the user's input and returns the current server
time.</p>
<input id="EnteredValue" type="text" />
<input id="EchoButton" type="button" value="Echo" onclick="EchoUserInput()" />
</div>
</form>
<hr />
<div>
<span id="Results"></span>
</div>
</body>
</html>

WebService.asmx:

<%@. WebService Language="C#" Class="WebService" %>

using System;
using System.Web;
using System.Web.Services;
using System.Web.Services.Protocols;
using System.Web.Script.Services;

[WebService(Namespace = "http://tempuri.org/")]
[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]
[ScriptService]
public class WebService : System.Web.Services.WebService
{
[WebMethod]
public string HelloWorld(String input)
{
System.Threading.Thread.Sleep(3000);
string inputString = Server.HtmlEncode(input);
if (!String.IsNullOrEmpty(inputString))
{
return String.Format("You entered {0}. The current time is {1}.", inputString, DateTime.Now);
}
else
{
return "The input string was null or empty.";
}
}
}

Hope this helps.

Let me know if you need more info.
You can also see this thread for more help:http://forums.asp.net/t/1115018.aspx

Change the position of content in a web page

Hi

Can any one please help me out by telling me where to search for the feature that google has used to change the position of the conetent in a page by simply dragging and dropping the content. This is the linkhttp://www.google.co.in/ig?hl=en. Or waht features of .Net can be used to achieve this.

u can use MS-AJAX...its very simple.....use the MS-AJAX control toolkit

http://ajax.asp.net/ajaxtoolkit/DragPanel/DragPanel.aspx

change the mode of a DETAILSVIEW to INSERT mode as soon as a NEW RECORD is inserted in the

Hi, In ASP.NET 2.0 with AJAX, i have a fairly long-size form. I have lots of DETAILSVIEW on screem inside UPDATEPANELS from AJAX. The postbacks occur corrrectly without updating the entire page.

Now, i want to automatically change the mode of a DETAILSVIEW to INSERT mode as soon as a NEW RECORD is inserted in the DETAILSVIEW.

How can i accomplish this ?

Alex

assuming that detailsview will return to readonly mode, you can set following in load_complete (not load)

If DetailsView1.CurrentMode = DetailsViewMode.ReadOnly Then DetailsView1.ChangeMode(DetailsViewMode.Insert)End If

hope this helps.

Jae.

Change the event that causes the popupcontrol to shows the control

I want to use popupcontrol with a textbox, but I want it shows the popup just when the onKeyDown event fires. How can I do it (if it can be done)?You'll want to look at modifying the way PopupControlBehavior.js's this.initialize function attaches its events. You'll probably need to customize the events a little, but it shouldn't require many changes.

Change the default async timeout error message

I can't believe this question hasn't been asked before... How do I change the message that is displayed to the user when an async postback has timed out? I've searched the scriptmanager documentation and tried to handle the asyncpostbackerror or whatever event (which doesn't fire on a timeout), but I can't figure out how to do it. Any hints will be appreciated. Thanks.Hi,

You can add your own error handler as the following code:
function StartAsyncPostBack() {
WebService.set_timeout(2000);
WebService.RunForLongTime(0, Complete, OnError); // call a method with the signature of?RunForLongTime(int);
}
function OnError(result) {// your error handler
alert("error: " + result.get_message());
}

Hope this helps.

Change TextBox Text and Force UpdatePanel to Update

Can somebody show me a way of forcing an updatepanel to update using javascript.

Thanks

Hi~ Once I used a button to trigger the update and invoked the button.click() in javascript..

I know this is not some elegant solution.. but you can give it a try when there's no better way~

Change textbox css class onfocus

I'd like to have a textbox that changes css classes (bgcolor primarily) when the user is typing in the box (onfocus). I'd also like to have the textbox validated onblur and if the textbox is invalid change css class again.

I've accomplished all of this using maskededit and maskededitvalidator, however for a basic string entry such as a name I don't want any mask characters to be used in the textbox. My app will be used by very computer illiterate people, and I'm pretty sure having the ____ in the box or even having spaces will cause a lot of confusion and trouble so I would like to avoid that.

What is the best way for me to accomplish this? Also FYI, I'm a former ASP/javascript developer trying to make the move to .net.

Your best bet is to register a .js file in your scriptmanager's Scripts collection.

In that .js file, create a function called pageLoad() (the framework automatically wires that for you to fire when all the other html elements and ajax compoennts are done loading).

In your pageLoad function add an event handler to your input control like so:

$addHandler($get('inputControlId'),'focus',handler);

handler is the name of a function that you define next.

function handler(ev){
Sys.UI.DomElement.toggleCssClass(ev.target,'onfocusclassname');

}

where 'onfocusclassname' is defined in your CSS document as the style you want applied to the control when the control has focus.

Hope that helps.


That helps a ton, that's basically what I wanted to do I wasn't sure exactly how to do it. And am still not 100% sure, such as where i register this .js file, but I can probably figure that out. I assume I would then make a 'blur' handler as well.

paul.vencill:

$addHandler($get('inputControlId'),'focus',handler);


Do I need to do this for each textbox? inputControlId appears to be hardcoded. I want to have this functionality for all text boxes in an application, which will be hundrerd of textboxes once all the pages add up.

And I guess I would have to write my own client side validation functions then, in order to make the text box red after an invalid entry.


Well, there's a number of ways to skin any cat, of course. First, your questino on registering; the way I prefer to do it is to use the scriptmanager on the page:

<asp:ScriptManager id='scm' runat='server'> <Scripts> <asp:ScriptReference Path='myscript.js' /> </Scripts></asp:ScriptManager>

Like any control, you could also register it in the codefile, your choice.

As for your question on the volume of handlers you need to add, the $addHandler function requires as its first parameter a reference to a DOM element (hence using $get('id'); which returns a reference to the element itself). If you want all your text inputs then use document.getElementsByTagName() and then filter inside a loop like so:

var inputs = document.getElementsByTagName("INPUT");var count = inputs.length;for (var i=0;iif(input.type && input.type.toUpperCase() =='TEXT') $addHandler(input,'focus',handler);}

Now, for extra fun, if you want to add both a focus and a blur handler to the same object, then instead of $addHandler you can use $addHandlers (with an 's'). It's a convenient shortcut: int he above function change the $addHandler line to:

$addHandlers(input,{'focus' : focusHandler, 'blur' : blurHandler});

As for adding your own validation; yes, I'd submit that it'd probably be easier than trying to get the validation controls to play nicely with your custom script. Just make sure to validate on the server, too, to catch values from clients that have javascript disabled.

Change Textbox background with ValidatorCallout.

Hi All,

I want to replicate what is done here:

http://www.asp.net/AJAX/AjaxControlToolkit/Samples/ValidatorCallout/ValidatorCallout.aspx

When the submit button is clicked, the 'name' and 'phone number' backgrounds change color...

Any help would be great.

Thanks

Keegan

Hi Keegan,

There is a pretty good sample contained inside the AJAX Control Toolkit's source code. You can find it under SampleWebSite\ValidatorCallout directory. Here is the sample code. Please pay attention to the "Bold" part.

<%@. 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"></script><html xmlns="http://www.w3.org/1999/xhtml"><head runat="server"> <title>Untitled Page</title> <style> .validatorCalloutHighlight { background-color: lemonchiffon; } </style></head><body> <form id="form1" runat="server"> <asp:ScriptManager ID="ScriptManager1" runat="server"> </asp:ScriptManager> <table> <tr> <td>Name:</td> <td><asp:TextBox runat="server" ID="NameTextBox" BorderStyle="solid" BorderWidth="1px" BorderColor="#a9a9a9" /></td> </tr> <tr> <td>Phone Number:</td> <td><asp:TextBox runat="server" ID="PhoneNumberTextBox" BorderStyle="solid" BorderWidth="1px" BorderColor="#a9a9a9" /></td> </tr> </table> <br /> <asp:RequiredFieldValidator runat="server" ID="NReq" ControlToValidate="NameTextBox" Display="None" ErrorMessage="b><br />A name is required."> <ajaxToolkit:ValidatorCalloutExtender runat="Server" ID="NReqE" TargetControlID="NReq" HighlightCssClass="validatorCalloutHighlight" /> <asp:RequiredFieldValidator runat="server" ID="PNReq" ControlToValidate="PhoneNumberTextBox" Display="None" ErrorMessage="b><br />A phone number is required.<div style='margin-top:5px;padding:5px;border:1px solid #e9e9e9;background-color:white;'><b>Other Options:</b><br /><a href='javascript:alert("No phone number available in profile.");'>Extract from Profile</a></div>"> <ajaxToolkit:ValidatorCalloutExtender runat="Server" ID="PNReqE" TargetControlID="PNReq" HighlightCssClass="validatorCalloutHighlight" Width="350px" /> <asp:RegularExpressionValidator runat="server" ID="PNRegEx" ControlToValidate="PhoneNumberTextBox" Display="None" ValidationExpression="((\(\d{3}\) ?)|(\d{3}-))?\d{3}-\d{4}" ErrorMessage="b><br />Please enter a phone number in the format:<br />(###) ###-####"> <ajaxToolkit:ValidatorCalloutExtender runat="Server" ID="PNReqEx" TargetControlID="PNRegEx" HighlightCssClass="validatorCalloutHighlight" /> <asp:Button ID="Button1" runat="server" Text="Submit"/><br /><br /> </form></body></html>

I hope this help.

Best regards,

Jonathan


Hi Jonathan,

Thank you very much for the reply. It pointed me in the right direction:

I created a class in my linked CSS file:.validatorCalloutHighlight{background-color:Red;}

and set the property of myValidatorCalloutExtender to call:HighlightCssClass="validatorCalloutHighlight".

Worked like a charm.

Thanks again.

Keegan

Change Tab Panel on Validation Failed.

Hai Guys,

I have 4 tab panels. The first panel contains all required fields. The other tabs having optional fields. My problem is, if some of the required fields are empty then the first tab is not shown, Its shows only currently selected tab. SetFocusOnError property is set to true in Required Field Validator. Tab container is placed inside UpdatePanel control. Please help me on this issue. Thanks in advance

Hi pbarunkumar,

The behavior you are expierencing is not the default behavior.

Could you please post a working code example which replicates this behavior? This way I can easily look into the problem!

Kind regards,
Wim


Hi Pbarunkumar,

The key to your problem is how to hide a Tab , so you should see my reply onthis thread. I have shown how to do it on the client and server side. Please be careful about the ActiveTabIndex property. When you hide the first tab, ActiveTabIndex must not be 0.

Best regards,

Jonathan

change scroll position on partial-page update?

I'm wanting to be able to change the scroll position to the bottom (or to an anchor) on an AJAX partial-page update. Any ideas? Can I fire a client-side javascript function after the update? Do I have to turn off MaintainScrollPositionOnPostback for the page?

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

Also, if you have specific scrolling logic when the UpdatePanel comes back, you can add it to EndRequest method in the following code (e.g. scrollTo)...

<script language="javascript" type="text/javascript"> var prm = Sys.WebForms.PageRequestManager.getInstance(); prm.add_initializeRequest(InitializeRequest); prm.add_endRequest(EndRequest); function InitializeRequest(sender, args) { ... } function EndRequest(sender, args) { ... } </script>

-Damien


Thanks... that's what I needed!

Brad


http://aspnet.4guysfromrolla.com/articles/111704-1.aspx

<pages smartNavigation="true"MaintainScrollPositionOnPostback="true"/>

Try this also

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

prm.add_beginRequest(beginRequest);

function beginRequest()
{
prm._scrollPosition = null;
}

</script>

Lety me know if this helpful to you

Change Object name in generated WSDL

Good day,

I have a Web Method that uses a simple custom object, name Client, as a parameter, and also returns a Client.

However, in the generated WSDL, I want "element name="Client" " to be changed to "element name="THE_CLIENT", but without changing the class name.

Is there a way to specify that an object should have another name in the wsdl, Something like [WebMethod(Description="DESCRIPTION")], but for a class?

Thank you, have a nice day!

Hi,

I think this link provide all information you need:http://msdn2.microsoft.com/en-us/library/2baksw0z.aspx

By default, an XML element name is determined by the class or member name. In a simple class named Book, a field named ISBN will produce an XML element tag <ISBN>, as shown in the following example.

Visual Basic

Copy Code

PublicClass BookPublic ISBNAsStringEndClass' When an instance of the Book class is serialized, it might' produce this XML:' <ISBN>1234567890</ISBN>.

C#

Copy Code

publicclass Book{publicstring ISBN;}// When an instance of the Book class is serialized, it might// produce this XML:// <ISBN>1234567890</ISBN>.

This default behavior can be changed if you want to give the element a new name. The following code shows how an attribute enables this by setting theElementName property of aXmlElementAttribute.

Visual Basic

Copy Code

PublicClass TaxRates < XmlElement(ElementName ="TaxRate")> _Public ReturnTaxRateAsDecimalEndClass

C#

Copy Code

publicclass TaxRates{ [XmlElement(ElementName ="TaxRate")]public decimal ReturnTaxRate;}

For more information about attributes, seeExtending Metadata Using Attributes. For a list of attributes that control XML serialization, seeAttributes That Control XML Serialization.

Best Regards

change mouse pointer on AJAX UPDATE

i can't understand why i do same page exacly the same (copy & past) and sometimes it worked OK sometime it said javascript error.

My goal is to Change mouse pointer while AJAX is updating something and after finishes to change it back. I have found some woderfull example

please take a look at it:

<%@dotnet.itags.org.PageLanguage="C#"AutoEventWireup="true"CodeFile="Default.aspx.cs"Inherits="_Default" %>

<!DOCTYPEhtmlPUBLIC"-//W3C//DTD XHTML 1.0 Transitional//EN""http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<htmlxmlns="http://www.w3.org/1999/xhtml">

<headrunat="server">

<title>Untitled Page</title>

</head>

<body>

<formid="form1"runat="server">

<div>

<asp:ScriptManagerID="ScriptManager1"runat="server">

</asp:ScriptManager>

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

var prm = Sys.WebForms.PageRequestManager.getInstance();

prm.add_initializeRequest(InitializeRequest);

prm.add_endRequest(EndRequest);

function InitializeRequest(sender, args)

{

$get('Container').style.cursor ='wait';

// Get a reference to the element that raised the postback,

// and disables it.

$get(args._postBackElement.id).disabled =true;

}

function EndRequest(sender, args)

{

$get('Container').style.cursor ='auto';

// Get a reference to the element that raised the postback

// which is completing, and enable it.

$get(sender._postBackSettings.sourceElement.id).disabled =false;

}

</script>

<asp:UpdatePanelID="UpdatePanel1"runat="server">

<ContentTemplate>

<asp:LabelID="Label1"runat="server"Text="Update Me"></asp:Label>

<br/>

<br/>

<asp:ButtonID="Button1"runat="server"OnClick="Button1_Click"Text="Button"/>

</ContentTemplate>

</asp:UpdatePanel>

</div>

</form>

</body>

</html>

whats wrong here?

hello.

well, i think that the code you've written will only change the cursor when it's over the container html control. btw, i'm not finding that control on the page you've posted...


well it worked few times. Here is a link to the original sample:

http://encosia.com/2007/01/01/improved-progress-indication-with-aspnet-ajax/

look at it and maybe it will be more clearer what i am up to


hello.

well, but in the case of that sample, the complete form is wrapped by a div element which is named container (and that's why the cursor changes with the previous code)...


ok so what would be my solution not nesceserily this particular one but i have an AJAX based website with master page and multiple content pages and i need

notify user when ajax completes any given task Best and many years know way is to change mouse cursor How can i do that besides this example? or maybe it needs some corrections?


hello.

i haven't run the example, but i think it's working. what i'm trying to tell you is that you're missing a div. if you look at the sample, you should see that the first child of the body is a div element named container. when you start a partial postback, it'll change the cursor for that element. since it is the top element, that means that while the mouse cursor is over the space ocuppied by the div, you'll see that cursor during a partial postback. since you don't have this div in the code you've shown, i'm assuming that it simply doesn't work.

you must keep in mind is that you'll only see that cursor when the mouse is OVER that element!


Thank you very much


one more thing i would like to ask you Now i put my master page in div with specified tag So if press any button it changes mouse cursor but if i hover onto a other button or textbox it changes cursor to default state only if am hovering onto label or sometext data i can see hourglass How can do that if something is going on no matter where you put your mouse on the DIV container the cursor still would be a hourglass?

Change Mask of MaskedEditExtender?

Is it possible to change the Mask of a MaskedEditExtender without posting back?

I have a field for telephone number in format "999-9999"

When the checkbox beside the textbox is checked, it should change to "(999)-999-9999" format, and should go back to previous format when unchecked.

Hi Seven21,

Try out this.

if (CheckBox1.Checked)

{

TextBox1_MaskedEditExtender.Mask ="999-9999";

}

else

TextBox1_MaskedEditExtender.Mask ="(999)-999-9999";

Change language in Calendar

Hello, can I change language in calendar? and how?

I have the same problem


To localize scripts as the Calendar one you must set in the scriptmanager the arguments:

<asp:ScriptManagerID="ScriptManager1"runat="server"EnableScriptGlobalization="true"EnableScriptLocalization="true"

Change in DragDropList in new release ?

Hello,

Back in Atlas Time (6 monthes ago), I used Garbin's great exemple for a drag and drop found here:
http://aspadvice.com/blogs/garbin/archive/2006/01/17/14730.aspx

Now, after updating to the latest releases of ASPnet Ajax, I cannot make it work.

I've changed the script reference call into:
<asp:ScriptReferenceName="Microsoft.Web.Resources.ScriptLibrary.PreviewScript.js"Assembly="Microsoft.Web.Preview"/>
<asp:ScriptReferenceName="Microsoft.Web.Resources.ScriptLibrary.PreviewDragDrop.js"Assembly="Microsoft.Web.Preview"/>

The drag function (using "draggableListItem" beaviour) works well but the drop ("dragDropList" beaviour) is bugged and I get the following javascript error :

'this._activeDragSource.get_dragDataType()' is null or is not an object

Has there been a change in dragDropList in the new release? I cannot see it listed in the documentation.

Thanks in advance

Hi,

I've modified the example and the following code is working for me:

<%@. Page %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" ><head id="Head1" runat="server"> <title>Widgets UI Example</title> <style type="text/css"> body { font-family:Verdana; font-size:11px; } .main { position:relative; width:710px; height:540px; margin:auto; } .list1 { position:absolute; left:0px; height:520px; width:340px; padding:10px 5px 10px 10px; } .list2 { position:absolute; right:0px; height:520px; width:340px; padding:10px 10px 10px 5px; } .item { background:#fff; margin-bottom:5px; background:#fff; } .itemContent { padding:5px; text-align:center; } .itemHandle { height:15px; background:#e5ecf9; overflow:hidden; border-top:solid 1px #3366cc; font-weight:bold; cursor:move; } .dropCue { border:dashed 1px #ff0000; margin-bottom:5px; } .emptyList{ font-weight:bold; text-align:center; } .centered { margin:auto; } .templates { visibility:hidden; } </style></head><body> <form id="form1" runat="server"> <asp:ScriptManager ID="scriptManager" runat="server"> <Scripts> <asp:ScriptReference Assembly="Microsoft.Web.Preview" Name="PreviewScript.js" /> <asp:ScriptReference Assembly="Microsoft.Web.Preview" Name="PreviewDragDrop.js" /> </Scripts> </asp:ScriptManager> <div class="main"><%-- Left Area --%> <div id="leftArea" class="list1"> <div id="content1" class="item"> <div id="content1Handle" class="itemHandle">Content 1</div> <div class="itemContent"> <asp:Login ID="myLogin" runat="server" CssClass="centered"></asp:Login> </div> </div> <div id="content2" class="item"> <div id="content2Handle" class="itemHandle">Content 2</div> <div class="itemContent"> <asp:TextBox ID="myTextBox" runat="server"></asp:TextBox> <asp:Button ID="myButton" runat="server" Text="ClickMe" /> </div> </div> </div><%-- Right Area --%> <div id="rightArea" class="list2"> <div id="content3" class="item"> <div id="content3Handle" class="itemHandle">Content 3</div> <div class="itemContent"> <asp:Calendar ID="myCalendar" runat="server" CssClass="centered"></asp:Calendar> </div> </div> </div><%-- Templates --%> <div class="templates"><%-- Drop Cue template --%> <div id="dropCueTemplate" class="dropCue"></div><%-- Empty template --%> <div id="emptyTemplate" class="emptyList">Drop content here.</div> </div> </div> </form> <script type="text/xml-script"> <page> <components><!-- Left Area --> <control id="leftArea"> <behaviors> <dragDropList dragDataType="HTML" acceptedDataTypes="'HTML'" dragMode="Move" direction="Vertical"> <dropCueTemplate> <template layoutElement="dropCueTemplate" /> </dropCueTemplate> <emptyTemplate> <template layoutElement="emptyTemplate" /> </emptyTemplate> </dragDropList> </behaviors> </control><!-- Right Area --> <control id="rightArea"> <behaviors> <dragDropList dragDataType="HTML" acceptedDataTypes="'HTML'" dragMode="Move" direction="Vertical"> <dropCueTemplate> <template layoutElement="dropCueTemplate" /> </dropCueTemplate> <emptyTemplate> <template layoutElement="emptyTemplate" /> </emptyTemplate> </dragDropList> </behaviors> </control><!-- Draggable items --> <control id="content1"> <behaviors> <draggableListItem handle="content1Handle" /> </behaviors> </control> <control id="content2"> <behaviors> <draggableListItem handle="content2Handle" /> </behaviors> </control> <control id="content3"> <behaviors> <draggableListItem handle="content3Handle" /> </behaviors> </control> </components> </page> </script></body></html>


Yes ! It works perfect.

Thank you very much Garbin ! Smile


It's a great example.

Many thanks

Any ideas how I could save the contents after dragging

Any help on how we can get the list contents after a drop event would be good

Thanks anyway


Mike


mike963:

Any ideas how I could save the contents after dragging

Any help on how we can get the list contents after a drop event would be good

That is what I would also like to know. Also could you please Garbin provide the same code without xmlscript but with Microsoft AJAX library?

Thanx


I've been able to use the following code to make elements draggable:

$create(Sys.Preview.UI.DraggableListItem, {'handle': $get('content1Handle')}, null, null, $get('content1'));

But I haven't been able to programatically attach dragDropList behaviors because I can't figure out how to get a reference to a template. I had it working in Atlas (see: http://forums.asp.net/thread/1411942.aspx) but I had problems updating the template manager to work with MS AJAX.


Not that this will help too much, but I've been attempting the same thing. I've been spending a lot of time trying to understand exactly what the differences are between how the xml-script is parsed and run vice the imperative methods that you (and I) are trying.

A few things of note...

First, I noticed that if you call Sys.Application.getComponents(), the .length property will reveal that the imperative method will show five components are present (one for each $create call if you're mod'ing garbin's example like I am). In the declarative version, there are 10. So, after some investigating it seems that the declarative model makes one component for each DragDropList and each DraggableListItem (each behavior) and another component for each control, as a Sys.UI.Control (rightArea, leftArea, content1, content2, content3). Not sure if that's relevant just yet, but I suspect it might be.

Second, dropCueTemplates are Sys.Preview.UI.Template objects, not 'Declarative Template' objects like in AlexL's previous work around.

I've made them imperatively, but that hasn't helped in part b/c I'm not sure I'm making all the initialization params right. Looking in the previewScript.debug.js file, it looks like there's four params expected, but when I reflect on the actual dropCueTemplate that is sitting in one of the list behavior objects, it looks liek only two of them are passed by the xml-script; those are the _layoutTemplate (to be expected; and it's the dropCueTemplate DomElement), and the _parentMarkupContext.

I tried passing the list behavior a dropCueTemplate by using both the $create(Sys.Preview.UI.Template and the =new Sys.Preview.UI.Template syntax, but I think it's coming down to not knowing how to build that parentMarkupContext right. I've also tried to build one of those to pass in, but so far no joy. $create says that it doesn't support the property and using the =new has no effect at all (no error, no success). I suspect that you have to call initialize to get it to do anything, but I'm not sure why it's throwing that 'not supported' error. The Sys.Preview.UI.Template.initialize() function just deals with really basic DOM manipulation (tests if the layoutelement has a parentnode, if so it removes it from its parent node...)

Well, anyway, I need to get back to work now. T hose are my thoughts, please post here if you guys find anything adn I'll do the same.

Paul


Sorry for the thread necromancy, bu thas anyone had any luck solving this yet? I'd *really* like to be able to handle the control via js instead of xml-script...

Paul


I am looking for an option to save the position of those dragged items. I tried including a floatingbehavior to the xml-script for that control and provided

move = "OnMove" attribute value. And on the OnMove i tried to Save Profile properties. It didn't work. Any suggestions ??


Just to mention I updated the code for Atlas RC1.

Source here :

http://blog.marjanenarnout.be/index.php?entry=entry070320-224307

Change in behavior of RegisterStartupScript

In Beta 1, it is requried to use the ScriptManager.RegisterStartupScript method, and this method requires that a control that is within the partial update is passed as the first parameter.

All my pages inherit the same BasePage, and I wan't to register a startup script every time a partial update occurs, regardless of where the update is done.

Please change this back so that the Page.ClientScript.RegisterStartupScript method can be used!

Einar

I need a page based RegisterStartupScript as well. I haven't seen anything from Microsoft mentioning that they would bring this back. Is there a way to run Java Script from a class file?

Thanks,

Jennifer


We can't properly support RegisterStartupScript itself since there's no way to know what people registered. However, we're considering an option to allow people to call a new method (or perhaps change an existing method) to register scripts that should always get included in the async post.

Thanks,

Eilon


Thats great news Eilon, crossing my fingers, would simplify things a great deal :-)

By the way, big thanks to the team for all the great sessions in Barcelona last week!

Einar


Eilon,

This would be great. If the RegisterStartupScript of the ScriptManager did not require a reference to a control in an update panel, life would be much easier. Thanks,

Mark

change image on accordion click

I have an image on my accordion header.

I want to change that image when somebody expands the header and show the original image when the header is collapsed.

Can somebody help me ?

Take a look at bug8730 and let us know if the fix helps you. You can download the latest non-release version from thesource code tab on the codeplex site.

Change full postback action from inner update panel...

Hi,

Is there a way to alter full postback to partial postback caused by outer update panels from usercontrol?Huh?Confused...I tried to add button control as an AsyncPostBackTrigger. No effect to change from a full page postback to partial one. No change whether I set properties like ChildrenAsTriggers to false/true and UpdateMode to Always/Conditional inner update panel, when a button or any control causes a postback action is pressed, it causes a full postback.


Parent:

<asp:UpdatePanel ID="upanelPage" ChildrenAsTriggers="false" UpdateMode="Conditional" runat="server">
<Triggers>
</Triggers>
<ContentTemplate>
<asp:UpdatePanel ID="upanelMainContent" ChildrenAsTriggers="false" UpdateMode="Conditional" runat="server">
<Triggers>
</Triggers>
<ContentTemplate>
<!-- Main Content --> <<-- my user control or other are displayed
</ContentTemplate>
</asp:UpdatePanel>
</ContentTemplate>
</asp:UpdatePanel>

User Control loaded to Parent...

<asp:UpdatePanel ID="updatePanel1" runat="server" UpdateMode="Conditional" ChildrenAsTriggers="false" >
<ContentTemplate>
<ajaxToolkit:TabContainer ...>
<ajaxToolkit:TabPanel ...>
<asp:MultiView...>
<asp:View...>
...
<asp:LinkButton...></asp:LinkButton>
<asp:Button...></asp:Button>
<asp:UpdatePanel ...>
<Triggers>
<asp:AsyncPostBackTrigger ControlID=.../>
</Triggers>
<ContentTemplate>
...
<asp:GridView...>
</asp:GridView>
...
</ContentTemplate>
</asp:UpdatePanel>
...
</asp:View...>
<asp:View...>
...controls...
</asp:View>
</asp:MultiView>
</ajaxToolkit:TabPanel>
<ajaxToolkit:TabPanel ...>

</ajaxToolkit:TabPanel>
...
</ajaxToolkit:TabContainer>
</ContentTemplate>
</asp:UpdatePanel>

UpdatePanel causes a Full Post Back no matter what properties you set on it.

If you are looking for better performing alternatives, look out for ScriptCallbacks or JSON Based Calls and this would require "some" work compared to ourmagic updatepanel!


Huh??ConfusedScriptCallbacks?ConfusedJSon Based Calls?Hmm...Does not know what are they or how to start with them? ..thanks for the reply..


Huh??ConfusedScriptCallbacks?ConfusedJSon Based Calls?Hmm...Does not know what are they or how to start with them? I was trying to control the postback action of outer update panel from the inside user control..thanks for the reply..


Hi,den2005

I found that the following code worked.

The Page:

<%@. Page Language="C#" %>

<%@. Register src="http://pics.10026.com/?src=WebUserControl2.ascx" TagName="WebUserControl2" TagPrefix="uc1" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head id="Head1" runat="server">
<title>UpdatePanel Tutorial</title>
<style type="text/css">
#UpdatePanel2 {
position: relative;
margin: 2% 5% 2% 5%;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:ScriptManager ID="ScriptManager1" runat="server">
</asp:ScriptManager>
<asp:UpdatePanel ChildrenAsTriggers="False" ID="UpdatePanel1" UpdateMode="Conditional"
runat="server">
<ContentTemplate>
<fieldset>
<legend>Parent UpdatePanel</legend>Last refresh
<%=DateTime.Now.ToString() %>
<br />
<asp:Button ID="Button1" runat="server" Text="Refresh Outer Panel" />
<uc1:WebUserControl2 ID="WebUserControl2_1" runat="server" />
</fieldset>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="Button1" EventName="Click" />
</Triggers>
</asp:UpdatePanel>
</div>
</form>
</body>
</html>

The UserControl:

<%@. Control Language="C#" ClassName="WebUserControl2" %>
<asp:UpdatePanel ChildrenAsTriggers="False" ID="UpdatePanel2" runat="server" UpdateMode="Conditional">
<ContentTemplate>
<fieldset>
<legend>Nested UpdatePanel</legend>Last refresh
<%=DateTime.Now.ToString() %>
<br />
<asp:Calendar ID="Calendar1" runat="server"></asp:Calendar>
</fieldset>
</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="Calendar1" />
</Triggers>
</asp:UpdatePanel>

Hope this help.

Best regards.

Jin-Yu Yin

change FilteredTextBoxExtender filter type dynamically

Hi,

Im trying to change the Filter Type of FilteredTextBoxExtender on a checkbox onClick handler.

(The textBox which is my traget control is also a the target control of an AutoCompleteExtender control).

The user can switch between searching an item by its Number ID or by Its name)

therefore I need to change the type dynamically according to the checked property of a check box.

it works fine until I try to change the valid characters. I get the following exception on client side:

Microsoft JScript runtime error: Sys.ArgumentTypeException: Object of type 'String' cannot be converted to type 'AjaxControlToolkit.FilterTypes'.
Parameter name: value

HTML:

<ajaxToolkit:FilteredTextBoxExtenderID="FilteredTextBoxExtender1"runat="server"BehaviorID="FilteredTextBoxTxtStock"TargetControlID="txtStkNum"FilterType="Numbers, Custom">

</ajaxToolkit:FilteredTextBoxExtender>

  
1function chkNameList_click()2 {34 var autoComplete = $find('AutoCompleteBehavior');5 var TextBoxFilter = $find('FilteredTextBoxTxtStock');67 $get('<%=txtStkNum.ClientID%>').value ="";89if($get('UserContext').checked ==true)//Names10 {11 $get('<%=txtStkNum.ClientID%>').className ="txtStockHeb";//right alignment (text box)12 TextBoxFilter.set_ValidChars("?????????????????????? ");1314 }15else//Numbers16 {17 $get('<%=txtStkNum.ClientID%>').className ="txtStockEng";//left alignment (text box)18 TextBoxFilter.set_FilterType("Numbers");19 }20 }

 Thanks,
Tal

Hi Tal88,

Based on my research , I think your problem is mainly caused by TextBoxFilter.set_FilterType("Numbers");

Below is the FilterTypes,

AjaxControlToolkit.FilterTypes.prototype = {
Custom : 0x1, //1
Numbers : 0x2, //2
UppercaseLetters : 0x4, //3
LowercaseLetters : 0x8 //4
}

So if you want to set the FilterTypes to Custom, you should use TextBoxFilter.set_FilterType(1);

Numbers will be TextBoxFilter.set_FilterType(2);

If the FilterTypes is set to "Custom,Numbers,LowercaseLetters", please use TextBoxFilter.set_FilterType(7); //1+2+4

My Ajax Control Toolkit's version is V10618.

I hope this help.

Best regards,

Jonathan

Change Event not fired when changed once or more then restored to its original value.

Hi.


I am trying to ATLAS-ize an existing application with lots of Master Detail controls.

As I don't want to write a heap of new code I am using UpdatePanels rather than writing web services even though my situation is similar to the one in the CascadingDropDown example (http://atlas.asp.net/atlastoolkit/CascadingDropDown/CascadingDropDown.aspx)


The problem I have though is that if I change the master listbox selected value (say from 0 to 1) then the Update Panel refreshes fine.

If I change it back from 1 to 0 the SelectedIndexChanged event does not fire leaving a load of incompatible info in the details listbox

I'm assuming that this is because when the page was first loaded the value was 0 so it does not recognize that a change has occurred.

I'd be grateful for advice on the optimum solution to this.

Ah Problem Semi Solved!


The first thing I was doing "wrong" was that my page overrides Load and Save PageStateFromPersistenceMedium and stores it in a DB and just passes the GUID back and forth in a hidden field. This obviously means the ViewState updates never made it into my page.

I would appreciate some advice on things I can override to get this functionality back however as some of the ViewState is pretty huge but required without a lot of extra coding. Is their any way I can replicate what is happening automatically with __VIEWSTATE to my own custom hidden input (hdnViewStateId) (i.e. get it automatically submitted on a call back, get it passed back in the XML envelope and automatically update the value with the new one)

The other thing I was doing wrong was that I'd left in an old school Response.Write in my page which knackered up the XML sent! (By the way is there any way I could have switched on any error logging which would have alerted me to this last issue?)


Ah Problem Semi Solved!


The first thing I was doing "wrong" was that my page overrides Load and Save PageStateFromPersistenceMedium and stores it in a DB and just passes the GUID back and forth in a hidden field. This obviously means the ViewState updates never made it into my page.

I would appreciate some advice on things I can override to get this functionality back however as some of the ViewState is pretty huge but required without a lot of extra coding. Is their any way I can replicate what is happening automatically with __VIEWSTATE to my own custom hidden input (hdnViewStateId) (i.e. get it automatically submitted on a call back, get it passed back in the XML envelope and automatically update the value with the new one)

The other thing I was doing wrong was that I'd left in an old school Response.Write in my page which knackered up the XML sent! (By the way is there any way I could have switched on any error logging which would have alerted me to this last issue?)


Your drop down list is set to do a autopostback, correct? This would translate to a partial postback given that it's within the update panel.

Given that you've turned off the standard viewstate mechanism provided by ASP.Net, the "change" isn't going to be noticed 'cause the runtime can't compare what "was" (in the viewstate) with what "is" (in the form post). However, you can...

Take a look at this Fiddler trace of a site I quickly built using the update panel to do what you're doing with a drop down list (this is taken when the drop-down list auto posts back to the server):

POST /public/testsites/atlaswebsite3/Default.aspx HTTP/1.1
Accept: */*
Accept-Language: en-us
Referer:http://www.ben-rush.net/public/testsites/atlaswebsite3/
Cache-Control: no-cache
Content-Type: application/x-www-form-urlencoded
delta: true
UA-CPU: x86
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)
Host:www.ben-rush.net
Content-Length: 305
Proxy-Connection: Keep-Alive
Pragma: no-cache

ScriptManager1=myupdatepanel&__EVENTTARGET=DropDownList1&__EVENTARGUMENT=&__LASTFOCUS=&__VIEWSTATE=%2FwEPDwUKLTgwNzIyNjA5NA9kFgICAw9kFgICAw9kFgJmD2QWAgIDDxBkZBYBZmRkrJaJXj2KU%2FOTLiUUKLu7RDDJunM%3D&DropDownList1=2&__EVENTVALIDATION=%2FwEWBALyq5BnAp3kj%2BUKApKLpYsGApOLpYsGRIPIbgqWzDqL6Q8VoLqfhZnR%2BlM%3D&

You could grep out of the form post the object that created the postbck (__EVENTTARGET), and what its postback value is (DropDownList1=2). You could store the state of the last selected item value in whatever mechanism you choose and do your own compare, even in your custom page_load.

Thanks. I reckon that's probably the way to go.

I was contemplating (but probably wouldn't have actually done) a pretty horrible solution as I was playing with adding my own

__VIEWSTATE

hidden input with the GUID and it almost works if I strip out the extra "," that I get on the form post from the redundant ASP.NET added control of the same name!

I still hadn't sussed out how to change the XML envelope to reflect that change though..


When you say "change the XML envellop to reflect that change" you're talking about changing the XML response from the server that contains all the delta bits for the clientside framework, right (the XML that directs the client code to do its DHTML tricks to update the content within the UpdatePanel)?

So, before we go any further - your problem is that you can now detect when the change is made, but the atlas server code still doesn't and, therefore, doesn't include the right junk in the XML response back to the client to update the doodads in your UpdatePanel control?


Yes that's correct.

BTW: I've had a look at your blog and I suspect you're going to tell me that you know how to do this.

I'm a bit torn on the best way of doing this as.

I reckon__EVENTTARGET is probably the more robust way of doing it even though I lose a lot of the benefits of the ASP.NET module (I need to figure out how to store and retrieve the initial values of controls without using view state and raise the change events myself)

If I try and hijack the __VIEWSTATE control for my own purposes then a lot of the code is written for me already but my solution could break if a new version of ATLAS or update to ASP.NET comes out!


Actually Ben.

I've tried your suggestion and it's trickier than I thought it would be.

The problem is that when I select the original value in the Master ListBox nothing is sent back to the browser!

I assume that this is some sort of optimisation to only send back the things which are different and (as far as ASP.NET knows from looking at the old ViewState) it doesn't have to send anything back as they are the same.

It looks like I am going to need to integrate it with ViewState somehow. For the time being I've commented out my overrides and am sending all ViewState to the Client to get it working.

However I would be extremely grateful for suggestions of ways to get around this issue and get the benefits of both ServerSide ViewState Storage and ATLAS.


...let me dink around a bit with some stuff on my side here and try to duplicate what you're running into more accurately. This has got me curious about several things going on...


Can you visit this page and tell me how accurately this matches your situation:http://www.ben-rush.net/public/testsites/atlaswebsite3/.

I have a textbox and a listbox, the textbox updates its content to the selected index of the listbox when the selectedindex changes. The viewstate for the listbox is off. I don't believe that the listbox requires viewstate for identification of changes because the "change" will only occur when the index is changed; therefore a form post that includes the listbox as an eventtarget will be seen as a selectedindexchanged event. I could be wrong, but I seem to remember this being the case (I did some viewstate optimizations for a shopping cart system a long, long time ago).

Regardless, look at these two fiddler dumps, one during change from index 0 -> 1 (value 1->2), the other from 1->0 (value 2->1). Both show the value of the listbox.

POST /public/testsites/atlaswebsite3/Default.aspx HTTP/1.1
Accept: */*
Accept-Language: en-us
Referer:http://www.ben-rush.net/public/testsites/atlaswebsite3/
Cache-Control: no-cache
Content-Type: application/x-www-form-urlencoded
delta: true
UA-CPU: x86
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)
Host:www.ben-rush.net
Content-Length: 288
Proxy-Connection: Keep-Alive
Pragma: no-cache

ScriptManager1=myupdatepanel&__EVENTTARGET=ListBox1&__EVENTARGUMENT=&__LASTFOCUS=&__VIEWSTATE=%2FwEPDwUJNTA5MjUzOTYxZGTFj5uiiDfrPSUZQz6IYXNKpb8xOQ%3D%3D&ListBox1=2&TextBox1=0&__EVENTVALIDATION=%2FwEWBwKJvNCXBgK9ueOMCQKy1sniBQKz1sniBQKw1sniBQKx1sniBQLs0bLrBlpXNeow%2BdPC39h7%2F1FxYfamkoLm&

And the other...

POST /public/testsites/atlaswebsite3/Default.aspx HTTP/1.1
Accept: */*
Accept-Language: en-us
Referer:http://www.ben-rush.net/public/testsites/atlaswebsite3/
Cache-Control: no-cache
Content-Type: application/x-www-form-urlencoded
delta: true
UA-CPU: x86
Accept-Encoding: gzip, deflate
User-Agent: Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.1; SV1; .NET CLR 1.1.4322)
Host:www.ben-rush.net
Content-Length: 288
Proxy-Connection: Keep-Alive
Pragma: no-cache

ScriptManager1=myupdatepanel&__EVENTTARGET=ListBox1&__EVENTARGUMENT=&__LASTFOCUS=&__VIEWSTATE=%2FwEPDwUJNTA5MjUzOTYxZGTFj5uiiDfrPSUZQz6IYXNKpb8xOQ%3D%3D&ListBox1=1&TextBox1=1&__EVENTVALIDATION=%2FwEWBwKJvNCXBgK9ueOMCQKy1sniBQKz1sniBQKw1sniBQKx1sniBQLs0bLrBlpXNeow%2BdPC39h7%2F1FxYfamkoLm&


I should probably mention that I have a trigger in the UpdatePanel as well.

I suspect that it may be a trigger optimisation causing the issue (for the same reason as previously described it can't realise that there is a change to process so returns an empty envelope)

<Triggers>

<atlas:ControlEventTriggerControlID="drpMasterListBox"EventName="SelectedIndexChanged"/></Triggers>

Well yes that is definitely working.

Do you have a trigger?

Is your UpdatePanel set to the same options as mine or is anything different?

(I haveMode="Conditional"RenderMode="inline")

In any event I'm thinking of doing it without update panels now and using a custom extender.

I was hoping that UpdatePanels would be a quick and dirty solution but I'm not progressing as fast as I wanted to and I suspect I may hit yet more obstacles because my UpdatePanel is in a UserControl which I was planning to embed in another UpdatePanel at Page Level.


No, I don't have a trigger. I changed my rendering modes to what you have, and it didn't change things (I wouldn't expect that it would). You can visit the same page URL I gave you earlier to confirm.

If you have a control in your update panel that does a postback automatically (say, the listbox control with its autopostback option on), then you have no need for a trigger. Triggers will only be useful for controls that don't postback automatically. I haven't researched triggers much, but if they're anything like binding objects then the control they're bound to needs to be AJAX savvy anyway.

Try turning off the trigger, I guess - and see what that does.


MartinSmithh:

The first thing I was doing "wrong" was that my page overrides Load and Save PageStateFromPersistenceMedium and stores it in a DB and just passes the GUID back and forth in a hidden field. This obviously means the ViewState updates never made it into my page.

well, though i haven't tried it, i think it's safe to assume that your field will allways be maintained if you add it to the page by using the registerhiddenfield of the clientscriptmanager api.