Showing posts with label user. Show all posts
Showing posts with label user. Show all posts

Wednesday, March 28, 2012

update several textboxes from different services

I am trying to write my first application using atlas. what i want is to have 3 labels and one textbox. and one button.

the user enters a word into the textbox and clicks the button. what i then want to happen is for all 3 labels to be populated by calls to 3 separate webservices. sounds simple enough but..

these webservices may take some time to return, and i don't want to postback the entire page and then the user have to wait for each service to return before the page reloads.

What i want is for each label to be updated independently, so label1 migth be updated before 2 and 3
and 3 might be updated before 2. but at least the time the user has to wiat before something is returned is only as long as it takes for the first label to be updated.

i've read the following article on codeproject
http://www.codeproject.com/Ajax/HelloAtlas.asp

but this just deals with a partial postback to the same page, which isn't what i need to do.

If anyone can help or point me in the direction of an article that does something similar to what i would like to do, i'd appreciate it loads.

hello.

well, the scenario you describe can be easilly achieved by using the client portion of atlas. check this page:

http://atlas.asp.net/docs/atlas/doc/services/consuming.aspx#simple


Thanks for the reply. funnily enough i'd just started reading that tutorial.

I have made some progress. i enter a value in a texbox click a button. then 2 webservices are called asyncronously (ws1 sleeps for 5 seconds and returns a string ws sleeps for 2 seconds and returns a string) the results from these ws are then displayed in 2 textboxes.

However in order for the results to update these textboxes i've had to use standard html tags, not asp.net labels, i guess because they are generated server side.

What i would like to do is combine what i have so far with the display opf a progress animation like in this codeproject article.

http://www.codeproject.com/Ajax/HelloAtlas.asp

i think what i'm asking is how can i control an update panel and updateprogress cotnrol via javascript.

all i want it to be able to is whilst the webservice is being called, display a little .gif, and then when the webservice returns output the results within a dif

below is my code so far. any help would be appreciated

<atlas:ScriptManagerID="ScriptManager1"runat="server"EnablePartialRendering="true"><Services><atlas:ServiceReferencePath="WebService.asmx"/><atlas:ServiceReferencePath="WebService2.asmx"/></Services></atlas:ScriptManager><div></div><inputid="inputName"/><inputid="buttonGo"type="button"value="GO"onclick="return OnbuttonGo_click()"/><atlas:UpdatePanelID="wsOne"runat="server"><ContentTemplate><inputid="Label1"type="text"/>

<inputid="Label2"type="text"/>

</ContentTemplate>

</atlas:UpdatePanel>function OnbuttonGo_click()

{

//Oh yes. method one gets called first but 2 returns first oh yes as ws one sleeps for 5 secs and ws2 only sleeps for 2.//now need to look at batching//and also need to look at how to update sections of the html page with the results.//can i use updatepanels?

requestSimpleService = WebService.testAsync(

document.getElementById(

'inputName').value,//params

OnCompleteOne,

//Complete event

OnTimeout

//Timeout event

);

//Call script proxy passing the input element data

requestSimpleService = WebService2.testAsync(

document.getElementById(

'inputName').value,//params

OnCompleteTwo,

//Complete event

OnTimeout

//Timeout event

);

returnfalse;

}

function OnCompleteOne(result)

{

document.getElementById(

'Label1').value = result;

}

function OnCompleteTwo(result)

{

document.getElementById(

'Label2').value = result;

}

function OnTimeout(result)

{

alert(

"Timed out");

}


Ok, made a bit more progress. i can now output my results to separate divs.

All i need to be able to do now is to display a .gif in each div until the function returns.

function OnCompleteOne(result)

{

document.getElementById(

'wsone').innerHTML = result;

}

function OnCompleteTwo(result)

{

document.getElementById(

'wstwo').innerHTML = result;

}

<atlas:UpdatePanelID="wsOnePanel"runat="server"><ContentTemplate><divid="wsone"></div><divid="wstwo"></div></ContentTemplate></atlas:UpdatePanel>


hello.

first, you don't need to use an updatepanel in this scenario. the updatepanel let's you refresh a portion of the page but it should only be used when you're transforming an aspx page into an atlas page. second, you can do what you want easilly: to do that, you just need to show the icon during the start method and hide it during the end method.


aha well i've got it working. basically after each webservice call i set the inner html of the divs to the animated gif.

Then on completion the oncomplete function is called, which overwrites the innerhtml with the result.

requestSimpleService = WebService.testAsync(

document.getElementById(

'inputName').value,//params

OnCompleteOne,

//Complete event

OnTimeoutOne

//Timeout event

);

//display .gif

document.getElementById(

'wsone').innerHTML ='<img src=blue_forward.gif />'//Call script proxy passing the input element data

requestSimpleService = WebService2.testAsync(

document.getElementById(

'inputName').value,//params

OnCompleteTwo,

//Complete event

OnTimeoutTwo

//Timeout event

);

//display .gif

document.getElementById(

'wstwo').innerHTML ='<img src=blue_forward.gif />'

Update UpdatePanel using JavaScript

Hi Everybody,

i want to load dynamically content from some user controls (with forms,or some data-controls) using atlas. So i use an UpdatePanel for loadingthe user control into a placeholder.

Using buttons for loading new content works fine. But i still want touse a function which is callable per javascript. I think this way ismore flexable than using the Buttons, becaus every button needs it'sown Sub-Routine. But i want to have a function with an Parameter forloading the new content.

Has anybody a good idea how to realize this? Working with Update()-Function of UpdatePanel-Control doesn't logically work.

Here is some code:

At first my test-function

1 <WebMethod()> _
2Public Function Test(ByVal intIdAs String)As Boolean
3 Dim contentNameAs String = intId &".ascx"
4Dim contentControlAs Control = Page.LoadControl(contentName)
5
6 PlaceHolder.Controls.Add(contentControl)
7
8 UpdatePanel.Update()
9Return True
10 End Function

I called this per JS-Function ...

1function test(intId) {
2 PageMethods.Test(intId);
3}

... per onClick-Method of a Link

1<a href="#" onclick="test(1);">Test</a>
2
3 <atlas:UpdatePanel ID="UpdatePanel" runat="server">
4 <ContentTemplate>
5 <asp:PlaceHolder ID="PlaceHolder" runat="server">
6 </asp:PlaceHolder>
7 </ContentTemplate>
8 <Triggers>
9 <atlas:ControlEventTrigger ControlID="Button1" EventName="Click" />
10 <atlas:ControlEventTrigger ControlID="Button2" EventName="Click" />
11 </Triggers>
12 </atlas:UpdatePanel>

But it doesn't work. I have tried so much.

Is there a possibilty to get User Controls generated HTML Code?
Or has anybody an idea for realizing this with an other way?

Thanks for all hints.

Regards,

AndréHi Andre,

The main problem with what you are attempting to do is that you are attempting to make a modification to the page without actually performing a postback. Executing the web service method "Test" from Atlas using the PageMethod.Test statement will execute your web method, but doesn't actually perform a postback and therefore you can't modify your page. The web method can really only return data, not have ASP.NET re-render part of the page.

A simple, but maybe not the best way of accomplishing this, is to use a hidden text field and a button to provide postback data. You set the value of the hidden text box to the data needed to create the user control (i.e. intId) and then click the button programmatically (i.e. button1.click). Then you have a common routine on the server, like your web method "test", that alters the page as necessary based upon the postback information.

HTH
Hi,

thank you. But isn't there another method for loadig content dynamically per ATLAS?
Or is there a possibility to create a new event, bind the UpdatePanel-Trigger and raise it with JavaScript?

I believe there must be a cleaner method than using a hidden textfield and call a button's sub.
How do you this?

Best regards,

André
Hi,

I am relatively new to ASP.NET and Atlas but have a similar question. Is there any way to generate an Update event on the UpdatePanel using client side Javascript?

I have a situation where I need to have two separate web applications for security reasons, but I want both applications to use a common search page. I can create a link on the first page (parent) to open the search page as a popup window easily enough. What I want to do is return the found item id back to the parent window and trigger an asynchronous update when the popup window is closed.

If I use javascript only, I can have a function in the parent window called 'Update()' and use it to create the xmlhttprequest object etc. I would prefer to use an Atlas UpdatePanel in the parent window and trigger an update from the popup window using the onunload event. (Note: the popup window page is not in the same application as the UpdatePanel)

Is this possible? Is there a better way to achieve this?

Regards,
Trevor.
OK, so I think we agree that a web method isn't going to do the trick for you as the page needs to go through its lifecycle and process the new UserControl and render it into Html.

There is no magic bullet in Atlas to load content dynamically. An UpdatePanel requires a postback to do any updating. You can use a web method to return an Html string to you and then parse it and place it where you want in the DOM, but that really is a lot of work and doesn't require an UpdatePanel.

That being said I'll assume that we agree that a postback needs to occur in order to load your user control into the page.

I believe you need a generalized method of posting back data that is not really related to a server control. The question remains; how to get the data back to the server on which control to load? The data has to be part of the post data. I suggest using a hidden text box as the transport mechanism as it's easy to work with and is fairly light weight and then telling that UpdatePanel to update through the use of clicking a hidden button. To be honest, I've used this pattern on a multi-million dollar application and have good success with it. I'm not saying it's perfect and maybe I'll see a better pattern that Ishould'veused, but it provides the flexibilty that you and I require.

Happy Coding
"Is there any way to generate an Update event on the UpdatePanel using client side Javascript?"

You need to have whatever is defined as a trigger of the UpdatePanel or a server control contained within the UpdatePanel cause a postback.

Happy Coding
Thanks for explaining that. I wasn't aware of the PageMethods collection until just now.

Trevor.

BUMP!!!

That worked Marvellously :)

I used it with a calendar control. I wanted to have different controls in a date cause a postback. WELL as far as I know adding sever controls doesn't work because they don't cause post backs when added inside a Day Cell.

SO dropped some anchors in the day. Had the onclick of the anchor fill a hidden field and click a button outside the updatepanel. Which triggered it :)

Works great.

updatepanel

Hi,

I am using updatepanel to update a message that's to be show to the user. I have a textbox with the submit button inside another updatepanel. Once the user hits a submit I have to display whatever he entered in the textbox.

The problem I am having is that the div (which displays result, can a server side control too), just appends the new text to the original value. So if I hit enter a multiple times, it goes on appending!

Am I missing something here?

Thanks!

Can you show the code that move the text from the textbox to the div?


Please show an example of what you are doing.


HtmlGenericControl DivControl = new HtmlGenericControl();

DivControl = (HtmlGenericControl)ResultsDiv;

DivControl.InnerHTML = txtReply.Text;

This comes up when the submit button's pressed.


Is there some reason you couldn't use a Label inside the div as your target? (I'm just trying to prevent the innerHTML thing from being the issue...)


hi, no, I tried label too. but did not work out. If you can paste the code for that, it would be really helpful.

Thanks!


I'm not sure why your code isn't doing what you expect it to, but here's some code that seems to work fine, using a Label:

<%@. 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 button_click(object sender, EventArgs e) { Label1.Text = TextBox1.Text; }</script><html xmlns="http://www.w3.org/1999/xhtml" ><body> <form id="form1" runat="server"> <asp:ScriptManager ID="ScriptManager1" runat="server" /> <asp:UpdatePanel ID="UpdatePanel1" runat="server"> <ContentTemplate> <asp:TextBox ID="TextBox1" runat="server" /> <asp:Button ID="Button1" runat="server" Text="Submit" OnClick="button_click" /> <asp:Label ID="Label1" runat="server" /> </ContentTemplate> </asp:UpdatePanel> </form></body></html>

Just a Small Correction, As you want to append the Text each time the button is pressed, the click handler should be:

protected void button_click(object sender, EventArgs e)
{
Label1.Text += TextBox1.Text;
}

Everything else is fine with the above example.


I thought he explicitlydidn't want to append?

From original post: "The problem I am having is that the div (which displays result, can a server side control too), just appends the new text to the original value. So if I hit enter a multiple times, it goes on appending!"


Sorry my mistake, the Requirment is not to append.


Hi mate, works like a charm! Thanks!

UpdatePanel

I am new to Ajax so please be patient. I have created a modal popup. The control has a simple textbox, button and gridview. When the user enters the search criteria the gridview is bound to a dataset with the results. There is a column in the grid that is a linkcolumn that is used to determine which result the user selected. The selected row info is placed into session in the code-behind click event, then there is a label on the form that kicks off javascript. This was all working well. I put all the controls into an updatepanel and everything is working great except the firing the javascript by placing the js code into the label. The Javascript never executes? Any help would be much appreciated.

Have you debug your code why javascript is not executing...

You can use RegisterClientScriptBlock Method to execute javascript..

See for more details...

http://ajax.asp.net/docs/mref/O_T_System_Web_UI_ScriptManager_RegisterClientScriptBlock.aspx


No luck. I am attempting to inject the javascript from code-behind into a label control. The label control is never updated with the Update Panel in place. Before the Update Panel this solution worked fine. I can put a button control on the page and it will execute the js fine. The big problem I see is getting the label text to update with the script.


Can you provide code details...

So if possible I'll try to find what exactly happens...

updatepanel - entire page posts back

I have a datagrid in an updatepanel. Clicking on anyrow in the datagrid changes the style to bold so the user knows they have selected it. On my development machine, clicking on the row updates only the panel as you would expect. Once on live server, clicking on a row in the datagrid posts back the entire page. Does anybody have any ideas as to what I can do to fix this.

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

<ContentTemplate>

<asp:GridViewID="reconGrid"runat="server"CssClass="gridTable"AutoGenerateColumns="false" AllowPaging="true"

PagerSettings-Mode="NumericFirstLast"PagerStyle-HorizontalAlign="right"PageSize="15"OnPageIndexChanging="reconGrid_PageIndexChanging"

OnRowDataBound="reconGrid_RowDataBound"CellPadding="2"Width="450px"OnRowCommand="reconGrid_RowCommand">

<AlternatingRowStyleCssClass="gridAltItemTr"/>

<RowStyleCssClass="gridItemTr"/>

<HeaderStyleCssClass="gridHeaderTr"ForeColor="white"/>

<Columns>

<asp:ButtonFieldText="SingleClick"CommandName="SingleClick"Visible="false"ButtonType="link"/>

<asp:TemplateFieldHeaderText="Clr">

<ItemTemplate>

<asp:CheckBoxID="cleared"runat="server"Enabled="false"Checked='<%# Convert.ToBoolean(Eval("CheckCleared")) %>'/>

</ItemTemplate></asp:TemplateField>

<asp:TemplateFieldHeaderText="Date">

<ItemTemplate>

<asp:LabelID="dateLbl"runat="server"CssClass="ssLabel"Text='<%# ((DateTime)Eval("TransactionDate")).ToShortDateString() %>'></asp:Label>

</ItemTemplate></asp:TemplateField>

<asp:TemplateFieldHeaderText="Chk #">

<ItemTemplate>

<asp:LabelID="chkLbl"runat="server"CssClass="ssLabel"Text='<%# Eval("CheckNumber") %>'></asp:Label>

</ItemTemplate>

</asp:TemplateField>

<asp:TemplateFieldHeaderText="Payee">

<ItemTemplate>

<asp:LabelID="payeeLbl"runat="server"CssClass="ssLabel"Text='<%# Eval("VendorName") %>'></asp:Label>

</ItemTemplate>

</asp:TemplateField>

<asp:TemplateFieldHeaderText="Amount">

<ItemTemplate>

<asp:LabelID="amountLbl"runat="server"CssClass="ssLabel"Text='<%# Eval("Amount") %>'></asp:Label>

</ItemTemplate>

<ItemStyleHorizontalAlign="right"/>

</asp:TemplateField>

<asp:TemplateFieldHeaderText="Type">

<ItemTemplate>

<asp:LabelID="typeLbl"runat="server"CssClass="ssLabel"Text='<%# Eval("Type") %>'></asp:Label>

</ItemTemplate>

</asp:TemplateField>

<asp:TemplateFieldHeaderText="FundTransactionsId"Visible="false">

<ItemTemplate>

<asp:LabelID="FundTransactionsId"runat="server"CssClass="ssLabel"Text='<%# Eval("Id") %>'></asp:Label>

</ItemTemplate>

</asp:TemplateField>

<asp:TemplateFieldHeaderText="AccountTransactionsId"Visible="false">

<ItemTemplate>

<asp:LabelID="AccountTransactionsId"runat="server"CssClass="ssLabel"Text='<%# Eval("AccountTransactionsId") %>'></asp:Label>

</ItemTemplate>

</asp:TemplateField>

</Columns>

</asp:GridView>

</ContentTemplate>

</asp:UpdatePanel>

See this related post:http://forums.asp.net/p/1069974/1558261.aspx

-Damien


I did look at that post and it didn't help. All the other ajax on my site seems to work like they should.


You have aScriptManger control on your page, right?

-Damien


Yes I do have a script manager. All you have to do on the server is install the ajax framework right? That's all I did on the server. All my other ajax works fine.


For a server install, all you should need is the AJAX Framework, yes. For Visual Studio 2005, you need Visula Studio SP1.

-Damien


Here are the entire contents of my aspx page. Different parts are made hidden or visible as you go from top to bottom. I have 2 update panels on the page. When you click on any row in the datagrid, the amounts in the other updatepanel are updated. So they both post back at the same time, just that on server, the entire page posts back.

<%@.PageLanguage="C#"AutoEventWireup="true"EnableEventValidation="false"CodeBehind="AccountDetail.aspx.cs"Inherits="SchoolFunds.AccountDetail" %>

<%@.RegisterAssembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"

Namespace="System.Web.UI"TagPrefix="asp" %>

<%@.RegisterAssembly="AjaxControlToolkit, Version=1.0.10618.0, Culture=neutral, PublicKeyToken=28f01b0e84b6d53e"

Namespace="AjaxControlToolkit"TagPrefix="ajax" %>

<%@.RegisterTagPrefix="uc1"TagName="Header"Src="../Share/controls/Header.ascx" %>

<!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>Account Details</title>

<scriptlanguage="javascript"src="../Share/css/util.js"></script>

<linkhref="../Share/css/global.css"type="text/css"rel="STYLESHEET">

<linkhref="../spreadsheet.css"rel="stylesheet"type="text/css"/>

</head>

<bodyclass="body"style="width: 100%">

<formmethod="post"runat="server">

<asp:ScriptManagerID="scriptmanger1"runat="server"></asp:ScriptManager>

<divclass="headerDiv"id="headers"><uc1:Headerid="ucHeader"runat="server"></uc1:header></div>

<ajax:AlwaysVisibleControlExtenderrunat="server"id="AlwaysVisibleControlExtender1"TargetControlID="allwaysOnMessage"VerticalOffset="117"HorizontalOffset="0"ScrollEffectDuration=".1"></ajax:AlwaysVisibleControlExtender>

<asp:PanelID="allwaysOnMessage"runat="server"BackImageUrl="~/bar1.gif"Width="755px"BorderWidth="1px"BorderStyle="Solid"BorderColor="buttonshadow">

<tablealign="left"style="vertical-align: middle; text-align: center; font-weight: bold;">

<tr>

<tdclass="dateLabel">Date</td>

<tdclass="typeLabel">Type</td>

<tdclass="numberLabel">Number</td>

<tdclass="dropdownLabel">Payee</td>

<tdclass="dropdownLabel">Account</td>

<tdclass="memoLabel">Memo</td>

<tdclass="ssMoneyTextBox">Increase</td>

<tdalign="right"style="width: 38px;">

<asp:Imagerunat="server"ID="aasdf"ImageUrl="~/images/check.gif"/>

</td>

<tdclass="ssMoneyTextBox">Decrease</td>

</tr>

</table>

</asp:Panel>

<br>

<asp:ValidationSummaryID="valSummary3"runat="server"ValidationGroup="valEdit"/>

<br>

<asp:ValidationSummaryid="valSummary"runat="server"ValidationGroup="validAdd"/>

<br>

<asp:ValidationSummaryid="valSummary1"runat="server"ValidationGroup="validEdit"/>

<br>

<asp:ValidationSummaryid="valSummary2"runat="server"ValidationGroup="validAddEmpty"/>

<asp:GridViewID="GridView1"runat="server"BorderColor="#DEDFDE"Width="750px"ShowHeader="true"HeaderStyle-BackColor="#FAFFF9"

BorderStyle="solid"BorderWidth="1px"AllowPaging="true"PageSize="15"CellPadding="4"ForeColor="Black"GridLines="Vertical"ShowFooter="false"

OnRowDataBound="GridView1_RowDataBound"OnPageIndexChanging="GridView1_PageIndexChanging"OnRowCommand="GridView1_RowCommand"AutoGenerateColumns="False"OnRowUpdating="GridView1_RowUpdating">

<RowStyleCssClass="row1"/>

<PagerStyleHorizontalAlign="right"BackColor="#E0F5E1"BorderStyle="solid"BorderWidth="1px"BorderColor="black"/>

<AlternatingRowStyleCssClass="row2"/>

<Columns>

<asp:ButtonFieldText="SingleClick"CommandName="SingleClick"Visible="false"FooterText="SingleClick"ButtonType="Link"CausesValidation="true"ValidationGroup="validEdit"/>

<asp:TemplateFieldVisible="false">

<HeaderTemplate>

</HeaderTemplate>

</asp:TemplateField>

<asp:TemplateFieldHeaderText="AccountTransactionsId"HeaderStyle-CssClass="ssHeader"Visible="false">

<ItemTemplate>

<asp:LabelID="AccountTransactionsIdLabel"runat="server"Text='<%# Eval("AccountTransactionsId") %>'CssClass="ssLabel"></asp:Label>

</ItemTemplate>

</asp:TemplateField>

<asp:TemplateFieldHeaderText="FundTransactionsId"HeaderStyle-CssClass="ssHeader"Visible="false">

<ItemTemplate>

<asp:LabelID="FundTransactionsIdLabel"runat="server"Text='<%# Eval("FundTransactionsId") %>'CssClass="ssLabel"></asp:Label>

</ItemTemplate>

<ItemStyleCssClass="ssCell"/>

</asp:TemplateField>

<asp:TemplateFieldHeaderText="TransferAccountId"HeaderStyle-CssClass="ssHeader"Visible="false">

<ItemTemplate>

<asp:LabelID="TransferAccountIdLabel"runat="server"Text='<%# Eval("TransferAccountId") %>'></asp:Label>

</ItemTemplate>

<ItemStyleCssClass="ssCell"/>

</asp:TemplateField>

<asp:TemplateField>

<HeaderStyleCssClass="ssHeader"HorizontalAlign="left"VerticalAlign="bottom"/>

<HeaderTemplate>

<asp:TextBoxID="DateAdd"runat="server"CssClass="ssDateTextBoxAdd"Visible="true"Width="70px"></asp:TextBox>

<ajax:TextBoxWatermarkExtenderID="DateAddWME"runat="server"TargetControlID="DateAdd"WatermarkText="Date"WatermarkCssClass="dateTextBoxWM"></ajax:TextBoxWatermarkExtender>

<asp:ImageButtonrunat="server"ID="dateAddImgBtn"CausesValidation="false"TabIndex="-1"ImageUrl="~/images/calendar button.bmp"Visible="true"/>

<asp:RequiredFieldValidatorID="reqDateAdd"runat="server"ErrorMessage="You must enter a transaction date."ControlToValidate="DateAdd"Display="static"ValidationGroup="validAdd">**</asp:RequiredFieldValidator>

<asp:rangevalidatorid="valDateAdd"runat="server"ErrorMessage="Transaction date is out of range or is incorrect format (mm/dd/yyyy)."

ControlToValidate="DateAdd"MaximumValue="12/31/9999"MinimumValue="1/1/1753"Type="Date"Display="Dynamic"ValidationGroup="validAdd">**</asp:rangevalidator>

<ajax:CalendarExtenderID="AddCalendar"runat="server"TargetControlID="DateAdd"Animated="true"PopupButtonID="dateAddImgBtn"></ajax:CalendarExtender>

</HeaderTemplate>

<ItemStyleCssClass="ssCell"VerticalAlign="bottom"/>

<ItemTemplate>

<asp:LabelID="DateLabel"runat="server"Text='<%# ((DateTime)Eval("TransactionDate")).ToShortDateString() %>'ToolTip='<%# ((DateTime)Eval("TransactionDate")).ToShortDateString() %>'CssClass="dateLabel"Width="70px"></asp:Label>

<asp:TextBoxID="DateText"TabIndex="1"runat="server"Text='<%# ((DateTime)Eval("TransactionDate")).ToShortDateString() %>'ToolTip='<%# ((DateTime)Eval("TransactionDate")).ToShortDateString() %>'Visible="false"CssClass="ssDateTextBox"Width="70px"></asp:TextBox>

<ajax:CalendarExtenderID="EditCalendar"runat="server"TargetControlID="DateText"Animated="true"PopupButtonID="dateEditImgBtn"></ajax:CalendarExtender>

<asp:RequiredFieldValidatorID="reqDate"runat="server"ErrorMessage="You must enter a transaction date."ControlToValidate="DateText"Display="dynamic"ValidationGroup="validEdit">**</asp:RequiredFieldValidator>

<asp:rangevalidatorid="valDate"runat="server"ErrorMessage="Transaction date is out of range or is incorrect format (mm/dd/yyyy)."

ControlToValidate="DateText"MaximumValue="12/31/9999"MinimumValue="1/1/1753"Type="Date"Display="Dynamic"ValidationGroup="validEdit">**</asp:rangevalidator>

<asp:ImageButtonrunat="server"ID="dateEditImgBtn"CausesValidation="false"TabIndex="-1"ImageUrl="~/images/calendar button.bmp"Visible="false"/>

</ItemTemplate>

</asp:TemplateField>

<asp:TemplateField>

<HeaderStyleCssClass="ssHeader"/>

<HeaderTemplate>

<asp:TextBoxID="typeAdd"CssClass="ssTypeTextBox"TabIndex="-1"runat="server"Width="33px"Enabled="false"></asp:TextBox>

</HeaderTemplate>

<ItemTemplate>

<asp:LabelID="TypeLabel"tabindex="-1"runat="server"Text='<%# Eval("TransactionType") %>'ToolTip='<%# Eval("TransactionType") %>'CssClass="typeLabel"Width="33px"></asp:Label>

<asp:TextBoxID="TypeText"TabIndex="-1"runat="server"Text='<%# Eval("TransactionType") %>'ToolTip='<%# Eval("TransactionType") %>'visible="false"CssClass="ssTypeTextBox"ReadOnly="true"></asp:TextBox>

</ItemTemplate>

<ItemStyleCssClass="ssCell"/>

</asp:TemplateField>

<asp:TemplateField>

<HeaderStyleCssClass="ssHeader"/>

<HeaderTemplate>

<asp:TextBoxID="CheckNumberAdd"runat="server"CssClass="ssNumberTextBoxAdd"Visible="true"Width="50px"></asp:TextBox>

<ajax:TextBoxWatermarkExtenderID="CheckNumberAddWME"runat="server"TargetControlID="CheckNumberAdd"WatermarkText="Number"WatermarkCssClass="numberTextBoxWM"></ajax:TextBoxWatermarkExtender>

</HeaderTemplate>

<ItemTemplate>

<asp:LabelID="CheckNumberLabel"runat="server"Text='<%# Eval("CheckNumber") %>'ToolTip='<%# Eval("CheckNumber") %>'CssClass="ssNumberTextBox"Width="50px"></asp:Label>

<asp:TextBoxTabIndex="2"ToolTip='<%# Eval("CheckNumber") %>'ID="CheckNumberText"runat="server"Text='<%# Eval("CheckNumber") %>'visible="false"CssClass="ssNumberTextBox"Width="50px"></asp:TextBox>

</ItemTemplate>

<ItemStyleCssClass="ssCell"/>

</asp:TemplateField>

<asp:TemplateField>

<HeaderStyleCssClass="ssHeader"/>

<HeaderTemplate>

<asp:DropDownListID="VendorNameAdd"runat="server"DataTextField="VendorName"DataValueField="Id"CssClass="ssDropDown"Visible="true"Width="150px"></asp:DropDownList>

</HeaderTemplate>

<ItemTemplate>

<asp:LabelID="VendorLabel"runat="server"Text='<%# Eval("VendorName") %>'ToolTip='<%# Eval("VendorName") %>'CssClass="dropdownLabel"Width="150px"></asp:Label>

<asp:DropDownListTabIndex="3"ID="VendorText"runat="server"Visible="false"DataTextField="VendorName"DataValueField="Id"CssClass="ssDropDown"Width="150px"></asp:DropDownList>

<asp:CustomValidatorrunat="server"ID="valVendor"ControlToValidate="VendorText"Display="dynamic">**</asp:CustomValidator>

</ItemTemplate>

<ItemStyleCssClass="ssCell"/>

</asp:TemplateField>

<asp:TemplateField>

<HeaderStyleCssClass="ssHeader"/>

<HeaderTemplate>

<br/>

<asp:DropDownListID="AccountNameAdd"runat="server"DataTextField="Account"DataValueField="Id"CssClass="ssDropDown"Visible="true"Width="150px"></asp:DropDownList>

<asp:RequiredFieldValidatorID="valAccountAdd"runat="server"InitialValue="-1"ControlToValidate="AccountNameAdd"ErrorMessage="You must select an account."ValidationGroup="validAdd">**</asp:RequiredFieldValidator>

<asp:CustomValidatorID="valAccountAddDDL"runat="server"Display="Dynamic"ControlToValidate="AccountNameAdd"ValidationGroup="validAdd">**</asp:CustomValidator>

</HeaderTemplate>

<ItemTemplate>

<asp:LabelID="AccountLabel"runat="server"Text='<%# Eval("Name") %>'ToolTip='<%# Eval("Name") %>'CssClass="dropdownLabel"Width="150px"></asp:Label>

<asp:DropDownListTabIndex="4"ID="AccountName"runat="server"Visible="false"DataTextField="Account"DataValueField="Id"CssClass="ssDropDown"Width="150px"></asp:DropDownList>

<asp:requiredfieldvalidatorid="RequiredfieldAccount"Display="Dynamic"ControlToValidate="AccountName"Runat="server"InitialValue="-1"ErrorMessage="You must select an account."ValidationGroup="validEdit">**</asp:requiredfieldvalidator>

<asp:CustomValidatorID="valAccountDDL"runat="server"Display="Dynamic"ControlToValidate="AccountName"ValidationGroup="valEdit">**</asp:CustomValidator>

</ItemTemplate>

<ItemStyleCssClass="ssCell"/>

</asp:TemplateField>

<asp:TemplateField>

<HeaderStyleCssClass="ssHeader"/>

<HeaderTemplate>

<asp:TextBoxID="MemmoAdd"runat="server"TextMode="multiline"CssClass="ssMemoTextBoxAdd"Visible="true"Width="110px"Height="50px"></asp:TextBox>

<ajax:TextBoxWatermarkExtenderID="MemoAddWME"runat="server"TargetControlID="MemmoAdd"WatermarkText="Memo"WatermarkCssClass="memoTextBoxWM"></ajax:TextBoxWatermarkExtender>

</HeaderTemplate>

<ItemTemplate>

<asp:LabelID="MemoLabel"runat="server"Text='<%# Eval("Memo") %>'ToolTip='<%# Eval("Memo") %>'CssClass="memoLabel"Width="110px"></asp:Label>

<asp:TextBoxTabIndex="5"ID="MemoText"runat="server"Text='<%# Eval("Memo") %>'ToolTip='<%# Eval("Memo") %>'visible="false"TextMode="multiline"CssClass="ssMemoTextBox"Width="110px"Height="50px"></asp:TextBox>

</ItemTemplate>

<ItemStyleCssClass="ssCell"/>

</asp:TemplateField>

<asp:TemplateField>

<HeaderStyleCssClass="ssHeader"/>

<HeaderTemplate>

<asp:TextBoxID="IncreaseAdd"runat="server"CssClass="ssMoneyTextBoxAdd"Visible="true"Width="65px"></asp:TextBox>

<ajax:TextBoxWatermarkExtenderID="IncreaseAddWME"runat="server"TargetControlID="IncreaseAdd"WatermarkText="Increase"WatermarkCssClass="moneyTextBoxWM"></ajax:TextBoxWatermarkExtender>

<asp:CustomValidatorrunat="server"ID="valIncreaseAdd"ControlToValidate="IncreaseAdd"Display="dynamic"ValidationGroup="validAdd">**</asp:CustomValidator>

<asp:RegularExpressionValidatorID="IncreaseAddRegExp"runat=serverDisplay="dynamic"ValidationExpression="\d*.?\d{2}"ControlToValidate="IncreaseAdd"ErrorMessage="Increase amount is not in a correct format. Enter all numbers without a '$' or commas."ValidationGroup="validAdd">**</asp:RegularExpressionValidator>

</HeaderTemplate>

<ItemTemplate>

<asp:LabelID="IncreaseLabel"runat="server"Text='<%# Eval("Increase") %>'ToolTip='<%# Eval("Increase") %>'CssClass="ssMoneyTextBox"Width="65px"></asp:Label>

<asp:TextBoxTabIndex="6"ID="IncreaseText"runat="server"Text='<%# Eval("Increase") %>'ToolTip='<%# Eval("Increase") %>'visible="false"CssClass="ssMoneyTextBox"Width="65px"></asp:TextBox>

<asp:RegularExpressionValidatorID="RegularExpressionValidator1"runat=serverDisplay="dynamic"ValidationExpression="^\d*?.\d{1,2}$"ControlToValidate="IncreaseText"ErrorMessage="Increase amount is not in a correct format. Enter all numbers without a '$' or commas."ValidationGroup="validEdit">**</asp:RegularExpressionValidator>

<asp:CustomValidatorrunat="server"ID="valIncrease"ControlToValidate="IncreaseText"Display="dynamic"ValidationGroup="validEdit">**</asp:CustomValidator>

</ItemTemplate>

<ItemStyleCssClass="ssCell"/>

</asp:TemplateField>

<asp:TemplateField>

<HeaderStyleCssClass="ssHeader"/>

<HeaderTemplate>

<asp:CheckBoxId="ClearedAdd"runat="server"CssClass="ssCheckBox"Visible="true"Width="28px"></asp:CheckBox>

</HeaderTemplate>

<ItemTemplate>

<asp:CheckBoxId="ClearedDisplay"runat="server"Checked='<%# Eval("CheckCleared") %>'Enabled="false"Width="28px"></asp:CheckBox>

<asp:CheckBoxTabIndex="7"Id="ClearedEdit"runat="server"Checked='<%# Eval("CheckCleared") %>'Visible=falseCssClass="ssCheckBox"Width="28px"></asp:CheckBox>

</ItemTemplate>

<ItemStyleCssClass="ssCell"/>

</asp:TemplateField>

<asp:TemplateField>

<HeaderStyleCssClass="ssHeader"HorizontalAlign="left"VerticalAlign="bottom"/>

<HeaderTemplate>

<asp:TextBoxID="DecreaseAdd"runat="server"CssClass="ssMoneyTextBoxAdd"Visible="true"Width="65px"></asp:TextBox>

<ajax:TextBoxWatermarkExtenderID="DecreaseAddWME"runat="server"TargetControlID="DecreaseAdd"WatermarkText="Decrease"WatermarkCssClass="moneyTextBoxWM"></ajax:TextBoxWatermarkExtender>

<asp:ButtonCommandName="Add"Text="Add"ID="btnAdd"Runat="server"CssClass="addButton"Visible="true"CausesValidation="true"ValidationGroup="validAdd"/>

<asp:RegularExpressionValidatorID="DecreaseAddRegExp"runat=serverDisplay="dynamic"ValidationExpression="\d*.?\d{2}"ControlToValidate="DecreaseAdd"ErrorMessage="Decrease amount is not in a correct format. Enter all numbers without a '$' or commas."ValidationGroup="validAdd">**</asp:RegularExpressionValidator>

</HeaderTemplate>

<ItemTemplate>

<asp:LabelID="DecreaseLabel"runat="server"Text='<%# Eval("Decrease") %>'ToolTip='<%# Eval("Decrease") %>'CssClass="ssMoneyTextBox"Width="65px"></asp:Label>

<asp:TextBoxTabIndex="8"ID="DecreaseText"runat="server"Text='<%# Eval("Decrease") %>'ToolTip='<%# Eval("Decrease") %>'visible="false"CssClass="ssMoneyTextBox"ValidationGroup="validEdit"Width="65px"></asp:TextBox>

<asp:ButtonTabIndex="9"Text="Add"ID="btnAddGrid"Runat="server"CssClass="addButton"CausesValidation="true"ValidationGroup="validEdit"OnClick="btnAddGrid_Click"visible="false"/>

<asp:RegularExpressionValidatorID="DecreaseRegExp"runat=serverDisplay="dynamic"ValidationExpression="\d*.?\d{2}"ControlToValidate="DecreaseText"ErrorMessage="Decrease amount is not in a correct format. Enter all numbers without a '$' or commas."ValidationGroup="validEdit">**</asp:RegularExpressionValidator>

</ItemTemplate>

<ItemStyleCssClass="ssCell"/>

</asp:TemplateField>

<asp:TemplateFieldHeaderText="IsVoid"HeaderStyle-CssClass="ssHeader"Visible="false">

<ItemTemplate>

<asp:LabelID="IsVoidLabel"runat="server"Text='<%# Eval("IsVoid") %>'CssClass="ssLabel"></asp:Label>

</ItemTemplate>

</asp:TemplateField>

</Columns>

</asp:GridView>

<tableid="tblAddEmpty1"runat="server"Visible="false"width="750px"bgcolor="#FAFFF9"cellspacing="0">

<tr>

<tdclass="ssHeader"valign="baseline">

<asp:TextBoxID="DateAddEmpty"runat="server"CssClass="ssDateTextBoxAdd"Width="70px"></asp:TextBox>

<ajax:TextBoxWatermarkExtenderID="DateAddEmptyWM"runat="server"TargetControlID="DateAddEmpty"WatermarkText="Date"WatermarkCssClass="dateTextBoxWM"></ajax:TextBoxWatermarkExtender>

<asp:RequiredFieldValidatorID="reqDateEmpty"runat="server"ErrorMessage="You must enter a transaction date."ControlToValidate="DateAddEmpty"Display="dynamic"ValidationGroup="validAddEmpty">**</asp:RequiredFieldValidator>

<asp:rangevalidatorid="valDateEmpty"runat="server"ErrorMessage="Transaction date is out of range or is incorrect format (mm/dd/yyyy)."

ControlToValidate="DateAddEmpty"MaximumValue="12/31/9999"MinimumValue="1/1/1753"Type="Date"Display="Dynamic"ValidationGroup="validAddEmpty">**</asp:rangevalidator>

<asp:ImageButtonID="calendarImgBtnEmpty"runat="server"TabIndex="-1"CausesValidation="false"ImageUrl="~/images/calendar button.bmp"/>

<ajax:CalendarExtenderrunat="server"ID="DateAddEmtpyExtender"PopupButtonID="calendarImgBtnEmpty"TargetControlID="DateAddEmpty"Animated="true"></ajax:CalendarExtender>

</td>

<tdclass="ssHeader">

<asp:TextBoxID="typeAddEmpty"CssClass="ssTypeTextBox"TabIndex="-1"runat="server"visible="true"Width="33px"Enabled="false"></asp:TextBox>

</td>

<tdclass="ssHeader">

<asp:TextBoxID="CheckNumberAddEmpty"runat="server"CssClass="ssNumberTextBoxAdd"Width="50px"></asp:TextBox>

<ajax:TextBoxWatermarkExtenderID="CheckNumberAddEmptyWME"runat="server"TargetControlID="CheckNumberAddEmpty"WatermarkText="Number"WatermarkCssClass="numberTextBoxWM"></ajax:TextBoxWatermarkExtender>

</td>

<tdclass="ssHeader">

<asp:DropDownListID="ddlVendorAddEmpty"runat="server"DataTextField="VendorName"DataValueField="Id"CssClass="ssDropDown"Width="150px"></asp:DropDownList>

</td>

<tdclass="ssHeader">

<br>

<asp:DropDownListID="ddlAccountAddEmpty"runat="server"DataTextField="Account"DataValueField="Id"CssClass="ssDropDown"Width="150px"></asp:DropDownList>

<asp:RequiredFieldValidatorID="valAccountAddEmpty"runat="server"InitialValue="-1"ControlToValidate="ddlAccountAddEmpty"ErrorMessage="You must select an account."ValidationGroup="validAddEmpty">**</asp:RequiredFieldValidator>

</td>

<tdclass="ssHeader">

<asp:TextBoxID="MemoAddEmpty"runat="server"TextMode="multiline"CssClass="ssMemoTextBoxAdd"Width="110px"Height="50px"></asp:TextBox>

<ajax:TextBoxWatermarkExtenderID="MemoAddEmptyWME"runat="server"TargetControlID="MemoAddEmpty"WatermarkText="Memo"WatermarkCssClass="memoTextBoxWM"></ajax:TextBoxWatermarkExtender>

</td>

<tdclass="ssHeader">

<asp:TextBoxID="IncreaseAddEmpty"runat="server"CssClass="ssMoneyTextBoxAdd"Width="65px"></asp:TextBox>

<ajax:TextBoxWatermarkExtenderID="IncreaseAddEmptyWME"runat="server"TargetControlID="IncreaseAddEmpty"WatermarkText="Increase"WatermarkCssClass="moneyTextBoxWM"></ajax:TextBoxWatermarkExtender>

<asp:RegularExpressionValidatorID="valIncreaseAddEmpty"runat=serverDisplay="dynamic"ValidationExpression="\d*.?\d{2}"ControlToValidate="IncreaseAddEmpty"ErrorMessage="Increase amount is not in a correct format. Enter all numbers without a '$' or commas."ValidationGroup="validAddEmpty">**</asp:RegularExpressionValidator>

<asp:CustomValidatorrunat="server"ID="valIncreaseAddEmpty1"ControlToValidate="IncreaseAddEmpty"Display="dynamic"ValidationGroup="validAddEmpty">**</asp:CustomValidator>

</td>

<tdclass="ssHeader">

<asp:CheckBoxId="ClearedAddEmpty"runat="server"CssClass="ssCheckBox"Width="28px"></asp:CheckBox>

</td>

<tdclass="ssHeader"valign="baseline">

<asp:TextBoxID="DecreaseAddEmpty"runat="server"CssClass="ssMoneyTextBoxAdd"Width="65px"></asp:TextBox>

<ajax:TextBoxWatermarkExtenderID="DecreaseAddEmtpyWME"runat="server"TargetControlID="DecreaseAddEmpty"WatermarkText="Decrease"WatermarkCssClass="moneyTextBoxWM"></ajax:TextBoxWatermarkExtender>

<asp:RegularExpressionValidatorID="valDecreaseAddEmpty"runat=serverDisplay="dynamic"ValidationExpression="\d*.?\d{2}"ControlToValidate="DecreaseAddEmpty"ErrorMessage="Decrease amount is not in a correct format. Enter all numbers without a '$' or commas."ValidationGroup="validAddEmpty">**</asp:RegularExpressionValidator>

<asp:ButtonText="Add"ID="btnAddEmpty"Runat="server"CssClass="addButton"CausesValidation="true"ValidationGroup="validAddEmpty"OnClick="btnAddEmpty_Click"/>

</td>

</tr>

</table>

<asp:PanelID="pageExtender"runat="server"Height="200px"></asp:Panel>

</form>

</body>

</html>


I finally got it to work. From this post: http://forums.asp.net/p/1095746/1653605.aspx#1653605

All I had to do was add<xhtmlConformancemode="Transitional"/>to web.config under system.web

UpdatePanel - DataGrid - Client Refresh

hi
I have a GridView inside a UpdatePanel


the case is: The user open a new window, select new items witch afect the data displayed in the DataGrid.

I want to update de GridView content via a Javascript method is there a way to do that?


thanks for any help

hello.

an easy way to do this is to add a dummy button and then perform a click programatically on that button. this should be enough to force the postback. you can also take a look at the postbackaction or event call the _dopostback method directly.


That Works fine
Thanks Madeira  
function RefreshGridView(){__doPostBack('Button1','');//Button.click();}

That Works fine
Thanks Luis Abreu
function RefreshGridView(){__doPostBack('Button1','');//Button.click();}

Does this only work from within the update panel?

I'm trying it from outside the panel and it is refreshing the whole page.

UpdatePanel - Javascript Refresh

hi
I have a GridView inside a UpdatePanel


the case is: The user open a new window, select new items witch afect the data displayed in the DataGrid.

I want to update de GridView content via a Javascript method is there a way to do that?


thanks for any help

I think this is possible. I've got the initial idea fromhere.
So put a hidden div into the UpdatePanel, for example:

<div style="display:none;">
<asp:Button id="btnHidden" runat="server" OnClick="btnHidden_Click" UseSubmitBehavior="false" /></div>

Then "trigger" this button in your popup window from javascript:

var refreshHelper = window.opener.document.getElementById( "btnHidden" );
refreshHelper.click( );

It works for me, but maybe there is smarter solutions than this.

hello.

well, currently you have 2 options: use the "dummy" button or use the postback action introduced by atlas.


Luis Abreu:

hello.

well, currently you have 2 options: use the "dummy" button or use the postback action introduced by atlas.

Luis (or anyone else), can you provide an example of using postback action? I'm trying to accomplish something very similar and the dummy button approach doesn't appeal to me.

-Lee


hello.

well, the dopostback action (or, if you want to use javascript, the __doPostBack method) will only work out correctly if there's a control placed inside the form which will be considered responsible for the postback.


Hi Luis,

I do have a a DropDownList that is inside the form so I that would work. I suppose I could just call the __doPostPack method, but I was hoping there would be something that was specific to ATLAS that would force the UpdatePanel to refresh.


hello again,

well, i guess that the answer is no, there isn't. and the reason is simple too: the update panel is just a delimiter that identifies a region which will be refreshed dinamically. all the partial postbacks are controlled by the pagerequestmanager object which uses the updatepanels defined on the page (normally divs or spans) to decide if it should perform a partial or a complete postback.


Ok, so what would you say would be the best way to accomplish this? It sounds as though the options are limited to the dummy button approach or explicitly calling __doPostBack.

hello again.

yep, that's it. i think that currently, there's no other option to perform that kind of operation.

Monday, March 26, 2012

UpdatePanel & ScriptManager Problem

Hi,I'm having a unusual problem I can see to solve. I'm new to AJAX and I'm finding fantastic.My problem is I have a user web control on a AJAX ASPX page with the ScriptManger.All the AJAX component work perfectly in the user web control except the following,

ScriptManager.RegisterClientScriptBlock(this,this.GetType(),"SearchMessage", msg,true);

The JavaScript is just a location.href or alert. I have no javascript errors I this is code in IFrame. Is there something different I need to do when accessing the script manager in the user web control?I can't find a solution and trying me crazy because I getting no errors and debugging tells me nothing.Really appreciate some help.thx

I sovled the problem so this thread is closed. I didn't realise I should of referenced the page above not the user web control class.

this.page instead of this

UPDATEPANEL (FindControl?)

I have an update panel with a place holder in which I load a user control when the page loads.

The user control has a button. What I would like is for that button to load another control in the update panel.

I thought I could utilize FindControl, but so far I am having no luck.

It is so easy to load controls into an update panel when the button is not contained in that update panel. But what if I want to use the update panel as if it were a frame?

Any ideas?

I tested to load user controls dynamically through asp:UpdatePanel.If you load user controls dynamically in Page_Load event handler,the loaded user controls can keep in a web all the time.Otherwise they will fade when there are any events to?be triggered.
Here are my testing codes for you.
User control 1:
<%@. Control Language="C#" AutoEventWireup="true" CodeFile="WebUserControl1.ascx.cs" Inherits="Web_User_Controls_WebUserControl1" %>
<table>
<tr>
<td><asp:Label ID="lblUserName" runat="server" Text="User Name"></asp:Label></td>
<td><asp:TextBox ID="tbUserName" runat="server"></asp:TextBox></td>
</tr>
<tr>
<td><asp:Label ID="lblPassword" runat="server" Text="Password"></asp:Label></td>
<td><asp:TextBox ID="tbPassword" runat="server"></asp:TextBox></td>
</tr>
<tr>
<td><asp:Button ID="btnLogon" runat="server" Text="Logon" /></td>
<td><asp:Button ID="btnCancel" runat="server" Text="Cancel" /></td>
</tr>
</table
Web User Control 2 to Load Web User Control 1:
<%@. Control Language="C#" AutoEventWireup="true" CodeFile="WUCLoadControls0.ascx.cs" Inherits="Web_User_Controls_WUCLoadControls0" %>
<asp:Label ID="lblLoadUserControl" runat="server" Text="Load User Controls Dynamically" BackColor="#C0FFC0"></asp:Label>
<asp:PlaceHolder ID="PH" runat="server"></asp:PlaceHolder>
<asp:Button ID="btnLoadControls" runat="server" Text="Load Another User Control" OnClick="btnLoadControls_Click" />

protected void btnLoadControls_Click(object sender, EventArgs e)
{
PH.Controls.Add(LoadControl("~\\Web User Controls\\WebUserControl1.ascx"));
}

.ASMX HTML:
<div>
<asp:UpdatePanel ID="upnlWaterMarkExtender" runat="server">
<ContentTemplate>
<asp:PlaceHolder ID="phLoadUserControl" runat="server"></asp:PlaceHolder>
</ContentTemplate>
</asp:UpdatePanel>
</div>
Page_Load Event Handler:
PlaceHolder phLoadUserControl = upnlWaterMarkExtender.FindControl("phLoadUserControl") as PlaceHolder;
phLoadUserControl.Controls.Add(LoadControl("~\\Web User Controls\\WUCLoadControls0.ascx"));

As a result,I find that?FindControl in asp:UpdatePanel can work fine.
Wish this can help you.

Well, how about this.

ON default.aspx, I have an updatepanel. In the updatepanel is a user control:

<asp:UpdatePanel ID="upMsg" runat="server" UpdateMode="Always">
<ContentTemplate>
<quarem:messages ID="msgcenter" runat="server" />
</ContentTemplate>
</asp:UpdatePanel>

Now, the user control simply contains a placeholder in which is loaded 1 of 2 user controls based on a session variable:

<asp:PlaceHolder ID="messagecenterplaceholder" runat="server" />

[code behind]
Page_Init
Select Case session("message")
Case "write"
(load write)
Case Else
(load read)
End Select

So, so far this is good. Everything works. The problem is when I actually load the read part.
There is a button that changes the session and then should update...

What I am trying is:

dim up as UpdatePanel = ctype(findcontrol("upMsg"), updatepanel)
up.update

But this does not work. It gives me the old "object reference not set to an instance of an object" error... so obviously FindControl is not finding the control.

Any suggestions?


I have the same problem. I can't find any dynamically added control to a placeholder (inside an UpdatePanel) with FindControl method.

UpdatePanel + StartupScript + Sys.Timer

I'm using an UpdatePanel with a user control somewhere in there. The usercontrol registers a client startup script (ClientScript.RegisterStartupScript) in which a Sys.Timer object is created.

When the updatepanel refreshes via Atlas, the startup script gets executed again (which I believe is expected behavior), causing a new Timer to be created.

The old timer is still around though, causing the tick event handler code to be executed twice as often as required.

What would be the best way to get around this? My current solution has been to update the startup script code to skip timer creation if a timer already exists. Another solution I could think of would be to call dispose() on the old timer at that time.

Is there a way to register client script to execute when an asynchronous postback occurs? In case the resulting updatepanel contents no longer contains the usercontrol with timer, it would be wise to dispose the timer at such a time.

Greetings,

Wouter

hello.

i think that you have several options...for instance, you could use the ispostback property of the page (it'll be false on the 1st rendering; since you only want to add the timer one time, this could solve your problem)...


Luis Abreu:

i think that you have several options...for instance, you could use the ispostback property of the page (it'll be false on the 1st rendering; since you only want to add the timer one time, this could solve your problem)...

Not really sure about IsPostBack. The scenario where I encountered this problem involved webparts in an updatepanel, where the timer is created by one of the webparts. When starting with a blank page and adding the webpart with timer, IsPostBack will be true.

Also, when this webpart is removed from the page, my feeling is that the timer should be stopped.


hello again.

hum...then, you can probably do something like this:

1. add the timer through xml-script
2. on the clientregistermethod, start the time
3. when the web part is removed, inject client script to stop it

Saturday, March 24, 2012

UpdatePanel + User Controls + javascript

I am have some problems executing some basic javascript from a user control within an update panel.

The UpdatePanel is as follows:

<atlas:UpdatePanel ID="DetailsPanel" Mode="Conditional" runat="server">
<ContentTemplate>
<div id="title_details" runat="server">
<asp:LinkButton ID="what"
OnClick="foo2"
Visible="false"
Font-Size="X-Small"
runat="server">
CLICK ME!
</asp:LinkButton>
</div>
</ContentTemplate>
</atlas:UpdatePanel>
The user control gets addes to the "title_details" div's controls as follows:

protected void foo(object sender, EventArgs e)
{
Control detailControl = (Control)Page.LoadControl("DetailsControl.ascx");
(detailControlas DetailsControl).upc_guid = (senderas LinkButton).CommandName;
title_details.Controls.Add(detailControl);
hideTitleBrowser();
what.Visible =true;
DetailsPanel.Update();
}

and the javascript is add as follows:

protected void Page_Load(object sender, EventArgs e) // in DetailsControl.ascx
{
using (BrowserGateway be =new BrowserGateway())
{
upc = be.getTitleByUpcGuid(1,"EN",upc_guid);
}
String scriptString ="function showTab( tab ){" +"var tabs = [\"tab1\",\"tab2\"];" +"for(i=0; i < tabs.length; i++){" +"var obj = document.getElementById(tabs[i]);" +"obj.style.display = \"none\";" +"}" +"var obj = document.getElementById(tab);" +"obj.style.display = \"block\";" +"}";

Page.ClientScript.RegisterClientScriptBlock(this.GetType(),"showHidetabs", scriptString);
}


Any ideas?Hi,

1) You should use only server controls inside an UpdatePanel, otherwise you may have troubles with the associated Atlas controls.

2) Try to register your script as a startup script instead of an inline script.

Hope it helps.

UpdatePanel and __doPostBack

My app loads one of several dynamically generated reports, implemented as user Controls, (*.ascx files) into an Update Panel. I am trying to do this without a page postback. However, client side code needs to validate several things before issuing the asynchronous request. In IE, I was using an ASP.Net custom Validator control hooked to a client side script
(GenerateReport(sender, e) {...}
to control this, (usinge.valid = true/false; to control whether the asynchronous request to update the content in the UpdatePanel was sent or not, but I have discovered that Firefox does not implement ASP.Net Validators properly.

So now I am trying to accomplish the same functionality simply using a client side script that calls __doPostBack(eventTarget, eventArgs);
But I can't seem to get the __doPostBack to call the Microsoft AJAX asynhcronous call, instead of doing a complete page postback.

How do I do that? Or is there a better way to do this.

Another option I have considered is to put the user control into a web service, that somehow just returns the innerHTML of the user5 control rendering process, but I can;t seem to figure that out either..

ideas anyone?

I've been fighting the same problem the last couple of days. Here is what I just finally came up with...

I write the __doPostBack on the server side and insert it into an onClick event on a control.

String sOnClick

="__doPostBack('" +this.UpdatePanel1.UniqueID +"','eventarg1$eventarg2');"; // the Update Panel's UniqueID will call the asynchronous request and pass the event argument string

e.Row.Attributes.Add("onClick",sOnClick); // I'm adding this to a gridview, I'm guessing this will work elsewhere too.

Then in the Page_Load I parse the event arguments and call the appropriate function

StringsEventArguments =this.Request.Params["__EVENTARGUMENT"];if(sEventArguments !=null)

{

Int32iDelimiter =sEventArguments.IndexOf('$');

StringsArgument =sEventArguments.Substring(iDelimiter + 1);

if (sEventArguments.StartsWith("eventarg1")) EventFunction(sArgument);

}

I hope this helps.

G


You canuse __doPostBack() to refresh an UpdatePanel, if you target the UpdatePanel itself.

Updatepanel and gridview

I want to have a gridview on my homepage and when a user pages through the results I want only to update the gridview and not the rest of the page.
I have the following code, but somehow this doesnt work, I get the error: Sys.Webforms.PageRequestManagerParserErrorException: the message received from the server could not be parsed.

<asp:UpdatePanel ID="pnlGuestbook" runat="server">
<ContentTemplate>

<asp:GridView ID="gvGuestBook" Width="250" CssClass="NotifyTable" DataSourceID="odsGuestBook" PageSize="2" AllowPaging="True" runat="server" AutoGenerateColumns="False" DataKeyNames="GBEntryID">
<Columns>
<asp:TemplateField>
<ItemTemplate>
<table>
<tr>
<td><br />
<%#GlobalFunctions.PrepareTextForHTML(Eval("Text"))%>
</td>
</tr>
</table>
</ItemTemplate>
</asp:TemplateField>
<asp:CommandField ButtonType="Button" >
<ItemStyle VerticalAlign="Top" />
</asp:CommandField>
</Columns>
<PagerSettings Mode="NumericFirstLast" FirstPageText="First" NextPageText="Next" LastPageText="Last" />
</asp:GridView>


<asp:ObjectDataSource ID="odsGuestBook" SelectCountMethod="GetTotalReturnedEntries" EnablePaging="true" OldValuesParameterFormatString="original_{0}" runat="server" UpdateMethod="UpdateGBEntry" DeleteMethod="DeleteGBEntry" SelectMethod="GetGBEntries" TypeName="GuestBookDAL">

</asp:ObjectDataSource>


</ContentTemplate>
<Triggers>
<asp:AsyncPostBackTrigger ControlID="gvGuestBook" EventName="PageIndexChanged"></asp:AsyncPostBackTrigger>
</Triggers>
</asp:UpdatePanel>I tested your codes in Visual Studio .Net 2005 with Ajax Beta 2 and found it worked fine.There was no any error taken place.Do you have any other settings in your Ajax website?Try to check the business logic layer and data access layer if there is error existed.
Try to check the web.config if it is similar to mine.
<?xml version="1.0"?>
<configuration>
<configSections>
<sectionGroup name="microsoft.web" type="Microsoft.Web.Configuration.MicrosoftWebSectionGroup, Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
<sectionGroup name="scripting" type="Microsoft.Web.Configuration.ScriptingSectionGroup, Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
<sectionGroup name="webServices" type="Microsoft.Web.Configuration.ScriptingWebServicesSectionGroup, Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
<section name="jsonSerialization" type="Microsoft.Web.Configuration.ScriptingJsonSerializationSection, Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false"/>
<section name="profileService" type="Microsoft.Web.Configuration.ScriptingProfileServiceSection, Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false"/>
<section name="authenticationService" type="Microsoft.Web.Configuration.ScriptingAuthenticationServiceSection, Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false"/>
</sectionGroup>
</sectionGroup>
</sectionGroup>
</configSections>
<connectionStrings>
<add name="AspForumsConnection" connectionString="Data Source=.;Initial Catalog=Performancing;UID=sa;PWD=Infy_1001"
providerName="System.Data.SqlClient" />
<add name="ProductConnectionString" connectionString="Data Source=.\SQLEXPRESS;AttachDbFilename=|DataDirectory|\Product.mdf;Integrated Security=True;User Instance=True"
providerName="System.Data.SqlClient" />
</connectionStrings>
<system.web>
<pages>
<controls>
<add tagPrefix="asp" namespace="Microsoft.Web.UI" assembly="Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add tagPrefix="asp" namespace="Microsoft.Web.UI.Controls" assembly="Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
</controls>
<tagMapping>
<add tagType="System.Web.UI.WebControls.CompareValidator" mappedTagType="Microsoft.Web.UI.Compatibility.CompareValidator, Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add tagType="System.Web.UI.WebControls.CustomValidator" mappedTagType="Microsoft.Web.UI.Compatibility.CustomValidator, Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add tagType="System.Web.UI.WebControls.RangeValidator" mappedTagType="Microsoft.Web.UI.Compatibility.RangeValidator, Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add tagType="System.Web.UI.WebControls.RegularExpressionValidator" mappedTagType="Microsoft.Web.UI.Compatibility.RegularExpressionValidator, Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add tagType="System.Web.UI.WebControls.RequiredFieldValidator" mappedTagType="Microsoft.Web.UI.Compatibility.RequiredFieldValidator, Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add tagType="System.Web.UI.WebControls.ValidationSummary" mappedTagType="Microsoft.Web.UI.Compatibility.ValidationSummary, Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
</tagMapping>
</pages>
<!--
Set compilation debug="true" to insert debugging
symbols into the compiled page. Because this
affects performance, set this value to true only
during development.
-->
<compilation debug="true">
<assemblies>
<add assembly="Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add assembly="System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/></assemblies>
</compilation>
<httpHandlers>
<remove verb="*" path="*.asmx"/>
<add verb="*" path="*.asmx" validate="false" type="Microsoft.Web.Script.Services.ScriptHandlerFactory, Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add verb="GET" path="ScriptResource.axd" type="Microsoft.Web.Handlers.ScriptResourceHandler" validate="false"/>
</httpHandlers>
<httpModules>
<add name="WebResourceCompression" type="Microsoft.Web.Handlers.WebResourceCompressionModule, Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add name="ScriptModule" type="Microsoft.Web.UI.ScriptModule, Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add name="MagicAjax" type="MagicAjax.MagicAjaxModule, MagicAjax" />
</httpModules>
<!--<sessionState mode="StateServer" stateConnectionString="tcpip=127.0.0.1:42424" timeout="1" cookieName="PHPSESS_ID@.PLANETRE" cookieless="UseCookies"/>-->
</system.web>
<system.webServer>
<validation validateIntegratedModeConfiguration="false"/>
<modules>
<add name="ScriptModule" preCondition="integratedMode" type="Microsoft.Web.UI.ScriptModule, Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
</modules>
<handlers>
<remove name="WebServiceHandlerFactory-ISAPI-2.0"/>
<add name="ScriptHandlerFactory" verb="*" path="*.asmx" preCondition="integratedMode" type="Microsoft.Web.Script.Services.ScriptHandlerFactory, Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add name="ScriptResource" verb="GET" path="ScriptResource.axd" type="Microsoft.Web.Handlers.ScriptResourceHandler"/>
</handlers>
</system.webServer>
</configuration

Good to know that my code IS actually working..now I've got to get it working for me as well :)

I checked if paging was possible if I took the gridview out of the updatepanel...that works..so it seem my business logic is working fine...

I cecked my web.config but Im unsure what to look for...here it is, perhaps you see something weird?
What I did see was that often is referred to Version=1.0.61025.0, I see that the version of the:
C:\Program Files\Microsoft ASP.NET\ASP.NET 2.0 AJAX Extensions\v1.0.61025\AJAXExtensionsToolbox.dll is 1.0.61025.0
while the version of my AjaxControlToolkit.dll (in the bin directory of my website) is 1.0.61020.0, but all my other AJAX stuff is working fine so that shouldnt be the problem right?

<?xml version="1.0"?>
<!--
Note: As an alternative to hand editing this file you can use the
web admin tool to configure settings for your application. Use
the Website->Asp.Net Configuration option in Visual Studio.
A full list of settings and comments can be found in
machine.config.comments usually located in
\Windows\Microsoft.Net\Framework\v2.x\Config
-->
<configuration>
<configSections>
<sectionGroup name="microsoft.web" type="Microsoft.Web.Configuration.MicrosoftWebSectionGroup, Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
<section name="converters" type="Microsoft.Web.Configuration.ConvertersSection"/>
<sectionGroup name="scripting" type="Microsoft.Web.Configuration.ScriptingSectionGroup, Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
<sectionGroup name="webServices" type="Microsoft.Web.Configuration.ScriptingWebServicesSectionGroup, Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
<section name="jsonSerialization" type="Microsoft.Web.Configuration.ScriptingJsonSerializationSection, Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false"/>
<section name="profileService" type="Microsoft.Web.Configuration.ScriptingProfileServiceSection, Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false"/>
<section name="authenticationService" type="Microsoft.Web.Configuration.ScriptingAuthenticationServiceSection, Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false"/>
</sectionGroup>
</sectionGroup>
</sectionGroup>
</configSections>
<microsoft.web>
<converters>
<add type="Microsoft.Web.Script.Serialization.Converters.DataSetConverter"/>
<add type="Microsoft.Web.Script.Serialization.Converters.DataRowConverter"/>
<add type="Microsoft.Web.Script.Serialization.Converters.DataTableConverter"/>
</converters>
</microsoft.web>
<appSettings>


</appSettings>

<system.web>
<!--
Set compilation debug="true" to insert debugging
symbols into the compiled page. Because this
affects performance, set this value to true only
during development.
Visual Basic options:
Set strict="true" to disallow all data type conversions
where data loss can occur.
Set explicit="true" to force declaration of all variables.
-->
<compilation debug="true" strict="false" explicit="true">
<assemblies>
<add assembly="Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add assembly="System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/></assemblies>
</compilation>
<pages maintainScrollPositionOnPostBack="true">
<controls>
<add tagPrefix="asp" namespace="Microsoft.Web.UI" assembly="Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add tagPrefix="asp" namespace="Microsoft.Web.UI.Controls" assembly="Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
</controls>
<tagMapping>
<add tagType="System.Web.UI.WebControls.CompareValidator" mappedTagType="Microsoft.Web.UI.Compatibility.CompareValidator, Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add tagType="System.Web.UI.WebControls.CustomValidator" mappedTagType="Microsoft.Web.UI.Compatibility.CustomValidator, Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add tagType="System.Web.UI.WebControls.RangeValidator" mappedTagType="Microsoft.Web.UI.Compatibility.RangeValidator, Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add tagType="System.Web.UI.WebControls.RegularExpressionValidator" mappedTagType="Microsoft.Web.UI.Compatibility.RegularExpressionValidator, Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add tagType="System.Web.UI.WebControls.RequiredFieldValidator" mappedTagType="Microsoft.Web.UI.Compatibility.RequiredFieldValidator, Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add tagType="System.Web.UI.WebControls.ValidationSummary" mappedTagType="Microsoft.Web.UI.Compatibility.ValidationSummary, Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
</tagMapping>
<namespaces>
<clear/>
<add namespace="System"/>
<add namespace="System.Collections"/>
<add namespace="System.Collections.Specialized"/>
<add namespace="System.Configuration"/>
<add namespace="System.Text"/>
<add namespace="System.Text.RegularExpressions"/>
<add namespace="System.Web"/>
<add namespace="System.Web.Caching"/>
<add namespace="System.Web.SessionState"/>
<add namespace="System.Web.Security"/>
<add namespace="System.Web.Profile"/>
<add namespace="System.Web.UI"/>
<add namespace="System.Web.UI.WebControls"/>
<add namespace="System.Web.UI.WebControls.WebParts"/>
<add namespace="System.Web.UI.HtmlControls"/>
<add namespace="Samples.AccessProviders"/>
</namespaces>
</pages>
<httpHandlers>
<remove verb="*" path="*.asmx"/>
<add verb="*" path="*.asmx" validate="false" type="Microsoft.Web.Script.Services.ScriptHandlerFactory, Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
</httpHandlers>
<httpModules>
<add name="WebResourceCompression" type="Microsoft.Web.Handlers.WebResourceCompressionModule, Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add name="ScriptModule" type="Microsoft.Web.UI.ScriptModule, Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
</httpModules>
<!--
The <authentication> section enables configuration
of the security authentication mode used by
ASP.NET to identify an incoming user.
-->
<urlMappings enabled="true">
<add url="~/Home.aspx" mappedUrl="~/Default.aspx?tabindex=0"/>
<add url="~/Forums.aspx" mappedUrl="~/Default.aspx?tabindex=1"/>
<add url="~/Faq.aspx" mappedUrl="~/Default.aspx?tabindex=2"/>
</urlMappings>
<authentication mode="Forms">
<forms name=".MyCookie" cookieless="AutoDetect" protection="All" loginUrl="Login.aspx" slidingExpiration="true" timeout="30" path="/">
<credentials passwordFormat="SHA1"/>
</forms>
</authentication>


<!--for cookies to work this must be enabled on client!-->
<roleManager enabled="true" cacheRolesInCookie="true" cookieName=".ASPXROLES" cookieTimeout="1" cookiePath="/" cookieRequireSSL="false" cookieSlidingExpiration="true" cookieProtection="All" defaultProvider="AccessRoleProvider" createPersistentCookie="false" maxCachedResults="25">
<providers>
<clear/>
<add name="AccessRoleProvider" connectionStringName="SQLAuth" applicationName="/Cust" type="Samples.AccessProviders.AccessRoleProvider"/>
</providers>
</roleManager>
<membership defaultProvider="AccessMembershipProvider" userIsOnlineTimeWindow="10">
<providers>
<clear/>
<add name="AccessMembershipProvider" type="Samples.AccessProviders.AccessMembershipProvider" connectionStringName="SQLAuth" requiresQuestionAndAnswer="true" applicationName="/Cust" minRequiredPasswordLength="2" enablePasswordRetrieval="true" enablePasswordReset="true" requiresUniqueEmail="true" passwordFormat="Clear" description="Stores and retrieves membership data from SQL Server"/>
</providers>
</membership>

<customErrors mode="Off">
</customErrors>
</system.web>
<location path="Members">
<!--This tells ASP.NET that the path "/Members" (the lead / is always implied)
should deny access to all unknown users. When someone tries to access a page
in /Members they will instead be redirected to the login.aspx-->
<system.web>
<authorization>
<deny users="?"/>
</authorization>
</system.web>
</location>

</configuration


I find there are great differences between your web.config and mine.
1.My ajax control toolkit dll file version is 1.0.61121.0,but yours is 1.0.61020.0.That means mine is later than yours.Maybe this can not lead to the problem as you said in your first post because you don't use Ajax controls in your codes.
2.There are the following configuration in my web.config,but not in yours.Maybe this could cause the problem to take place.Try to add them in your web.config.
<system.webServer>
<validation validateIntegratedModeConfiguration="false"/>
<modules>
<add name="ScriptModule" preCondition="integratedMode" type="Microsoft.Web.UI.ScriptModule, Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
</modules>
<handlers>
<remove name="WebServiceHandlerFactory-ISAPI-2.0"/>
<add name="ScriptHandlerFactory" verb="*" path="*.asmx" preCondition="integratedMode" type="Microsoft.Web.Script.Services.ScriptHandlerFactory, Microsoft.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add name="ScriptResource" verb="GET" path="ScriptResource.axd" type="Microsoft.Web.Handlers.ScriptResourceHandler"/>
</handlers>
</system.webServer>

3.Try to create a new Ajax enabled website to test your codes to check if it works.At least mine works fine now.
Wish the above can give you some helps.

Wednesday, March 21, 2012

Updatepanel and Literal control

I have a customer search dialog.

The user selects a row from the grid and Literal control is updated with Javascript which should close the dialog should then close and a customer account number field on the parent page should be updated.

This all works until I put the grid inside an Updatepanel - then selecting a row does cause the Literal cojntrol to be updated.

From some testing it seems that the Updatepanel is the cause of the problem - its not letting the grid update the Literal control when it is outside the Updatepanel (And when the Literal control is inside the Updatepanel - updating it doesnt do anything)

I think I can update the Literal control using something like Page.FindControl. However, I have been told that this breaks encapsulation and that I should raise an event from the grid and have the Literal control grab it.

Is raising an event the best solution ?

Updating a Literal with script used to be a great tool for me when I was doing 1.1 development, and posting back all of the time. Setting it with script won't cause the page to execute it unless the page were reloaded.

In this example, you should be fine with removing the UpdatePanel for a dialog box scenario, as a postback will simply cause the dialog window to close.


But I want the UpdatePanel on the dialog box - the user could run a number of searches for a customer before selecting one (Dont think I mentioned that) so I dont want to keep refreshing the whole thing if I can avoid it.
No, you didn't mention that. :)

UpdatePanel and Javascripts confirm

I have a delete button inside an UpdatePanel. I need to display a confirm popup, so that the user can confirm if he wants to delete or not. The Update has its UpdateMode as "Conditional", and, inside the Button's on_click event, I have the following code:

protected void ImageButton1_Click(object sender, ImageClickEventArgs e)
{
string script = "<script language='javascript'> confirm('Are you sure you want to change this selection ? ')</script>";
ScriptManager.RegisterClientScriptBlock(Button1, typeof(Button), "Popup", script, false);


GridView1.SelectedIndex = 1;

// here goes the code that erases from the database
}

The weird thing is that the GridView.SelectedIndex statement is always executed, and it doesn't even wait for the user to select OK or CANCEL from the Confirm dialog.

My question is, how can I get the return values from the confirm dialog? Is it possible? If it isn't possible, how can I achieve that the code is executed only if the user press "OK"?


I've read some really good answers in this forum, I hope you can help me.

Thanks!!

 You should add an onclick event to your delete button.

MyButton.Attributes.Add("onclick","return confirm('my message');")

The 'return' statement will exit the click event without firing a postback if cancel was clicked. If ok is clicked, the event fires like normal.


I tried this and it doesn't work. I wrote the code on the page_load event, but when I click the button, it does fire the Button_click event but doesn't display the dialog . I am sure it has to do with the UpdatePanel that I added to the page. The only way I have found to display the dialog is the one I posted before, using the ScriptManager.RegisterClientScriptBlock. I added the return in the following statement, but it still doesn't work, it still executes the code that follows without waiting for the user's answer.


ScriptManager.RegisterClientScriptBlock(Button1, typeof(Button), "Popup", "return confirm('my message');", true);


It works fine for me. I'm a VB guy, but luckily translating wasn't too hard. Here's a complete page in C#:

code-behind file:

using System;using System.Data;using System.Configuration;using System.Collections;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Web.UI.HtmlControls;public partialclass ConfirmOnUpdatePanel : System.Web.UI.Page{protected void Page_Load(object sender, EventArgs e) {this.ImageButton1.Attributes.Add("onclick","return confirm('Continue?');"); }protected void ImageButton1_Click(object sender, ImageClickEventArgs e) {this.ImageButton1.AlternateText ="Clicked " + System.Convert.ToString(DateTime.Now); }}

aspx code:

<%@. Page Language="C#" AutoEventWireup="true" CodeFile="ConfirmOnUpdatePanel.aspx.cs" Inherits="ConfirmOnUpdatePanel" %><!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></head><body> <form id="form1" runat="server"> <div> <asp:ScriptManager ID="ScriptManager1" runat="server"> </asp:ScriptManager> </div> <asp:UpdatePanel ID="UpdatePanel1" runat="server"> <ContentTemplate> <asp:ImageButton ID="ImageButton1" runat="server" AlternateText="Delete" OnClick="ImageButton1_Click" /> </ContentTemplate> </asp:UpdatePanel> </form></body></html>


I copied and pasted you posted and it still didn't work. So, I took the Button.Attributes.Add out of the page load and, instead, put it in the Button_clicked event. Now, the behavior changed. The first time you click the button , it doesn't do anything. Then, you click it again and it works ok.

I tried putting the code of the Button.Attributes both in the page_load event and the button_clicked event and it does the same thing: doesn't shows up the first time.

Any idea why this happens?

The .aspx I'm using is the same that you posted here and the .aspx.cs is the following:

using System;

using System.Data;

using

System.Configuration;

using

System.Collections;

using

System.Web;

using

System.Web.Security;

using

System.Web.UI;

using

System.Web.UI.WebControls;

using

System.Web.UI.WebControls.WebParts;

using

System.Web.UI.HtmlControls;

public

partialclassConfirmOnUpdatePanel : System.Web.UI.Page

{

protectedvoid Page_Load(object sender,EventArgs e)

{

}

protectedvoid ImageButton1_Click(object sender,ImageClickEventArgs e)

{

this.ImageButton1.Attributes.Add("onclick","return prompt('Continue?');");this.ImageButton1.AlternateText = System.Convert.ToString(DateTime.Now);

}

}

Thanks in advance!

UpdatePanel and ModalPopupExtender control

Hello all

For my error messages I'm using a ModalPopupExtender with a red background to show the user has done something wrong.
If for example the user types in a bad username/password combination, it does a postback and after that it shows me the ModalPopup.

This works fine!

But I want to use the UpdatePanel control of course to make it more smooth, nicer and application alike.

When I put the ModalPopupExtender and Panel (both are on my masterpage) in an UpdatePanel like this:

<ajax:UpdatePanel id="myUpdatePanel" runat="server">
<ContentTemplate>

<toolkit:ModalPopupExtender ID="errorModalPopup"
runat="server"
TargetControlID="btnHidden"
PopupControlID="ErrorPanel"
CancelControlID="btnApply"
DropShadow="true"
BackgroundCssClass="ErrorModalPopupClass"
BehaviorID="test2">
</toolkit:ModalPopupExtender>

<asp:Panel ID="ErrorPanel" runat="server" CssClass="ErrorPanelSettingsClass" Style='display:none' DefaultButton='btnApply'>
<asp:Label ID="lblErrorMessage" runat="server"></asp:Label><br />
<asp:ImageButton ID="btnApply" ImageUrl="~/Images/icons/apply.png" runat="server" CssClass="ApplyButton" />
</asp:Panel>

<div style='display: none'>
<asp:Button ID="btnHidden" runat="server" />
</div>

</ContentTemplate>
</ajax:UpdatePanel>

When I now put my Login Control on my Login.aspx page also into an UpdatePanel, it doens't work as expected. When I click the Login button, nothing happens...

Does anybody know how to achieve this? I really like this solution.

thx !

Gerrie

Please try your scenario with the recently available61106 release of the Toolkit (and ASP.NET AJAX Beta 2). If the problem persists, then please reply with acomplete, self-contained sample page that demonstrates the problem so that we can investigate the specific behavior you're seeing. Thank you!

David,

I don't know if you finally got the sample you needed or not. But so you know, I do have the latest update to the toolkit. However I can't get the modalpopup and updatepanel to work together properly. And that's not to mention the funny issue of the popup sometimes showing up automatically and without being triggered from the code. I saw others had that problem, too.

Anyways, here is a self-contained test page for you. It is based on some code initiallyborrowedfrom Ted Glaza, changed to VB, then AJAX, then simplified and then changed to fit this sample! :)

Any solution or workaround you can provide me with, is highly appreciated. I'm already in a time crunch and don't have the luxury of playing around with these controls. By the way, in real life,my popup control has to be launched from imagebuttons in a DataGrid. All are created on the server-side and I can't change that design easily.

Thanks,

Kathy

<%

@.PageLanguage="VB" %>

<%

@.RegisterAssembly="AjaxControlToolkit"Namespace="AjaxControlToolkit"TagPrefix="ajaxToolkit" %>

<!

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

<

scriptrunat="server">ProtectedSub CommandButton_OnSelect(ByVal senderAsObject,ByVal eAs CommandEventArgs)Dim IDAsInteger =CInt(e.CommandArgument)Dim xAs System.Xml.XmlNode = Data.GetXmlDocument.SelectSingleNode(String.Format("descendant::item[@.id='{0}']", ID))IfNot IsNothing(x)Then

myDynamicLabel.Text =

"The URL is: " & x.Attributes("url").ValueElse

myDynamicLabel.Text =

"Item with ID: " & ID.ToString &" could not be found."EndIf

ModalPopupExtender.Show()

EndSub

</

script>

<

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

<

headrunat="server"><title>Untitled Page</title><styletype="text/css">

/*Modal Popup*/

.modalBackground

{background-color:Gray;filter:alpha(opacity=70);opacity:0.7;

}

.modalPopup

{background-color:#FFF8C6;border-width:3px;border-style:solid;border-color:Gray;padding:3px;width:350px;

}

</style>

</

head>

<

body><formid="form1"runat="server"><asp:ScriptManagerID="ScriptManager1"runat="server"EnablePartialRendering=true/><p>

Some nonsense text to show the postback. blah di blah.

kjdhfjkh ksdhhsdfhj haunnsdju urfh kjhdjkf kjhdflgkh hr ujseopop';ui;j m[plio;l hjyryawre ghvnb mdfb jyutet ihe lijj huhiut hiuhvnmx mnbuyteruy gwerbmbnhfghtf jhel/krtjk ih banvdhtsfr cvnhfhtfd wklieth bnhdchzgf dejhfgkuhgr jwhg

lusyfiuysdkj jutyujefg jgdfjhg hjdgfhjg dkjf jkhgdsf uytser bvioy yhsejehyj mjnbcvjytyue rvkiuyd h j vihbrtkj f

</p><p>

Some nonsense text to show the postback. blah di blah.

kjdhfjkh ksdhhsdfhj hak kkfguhe mndfgkjh dkjg hzsnmbrtulk typi ,bngf aytwr eb mbhjvu ;orijnjm BFMhbmhdfbv ghvme hjmhg fbmbmnb mnbz

unnsdju urfh lusyfiuysdkj jutyujefg jgdfjhg hjdgfhjg dkjf jkhgdsf uytser bvioy yhsejehyj mjnbcvjytyue rvkiuyd h j vihbrtkj f

</p><p>

Some nonsense text to show the postback. blah di blah.

kjdhfjkh ksdhhsdfhj haunnsdju urfh lusyfiuysdkj jutyujefg jgdfjhg hjdgfhjg dkjf jkhgdsf uytser bvioy yhsejehyj mjnbcvjytyue rvkiuyd h j vihbrtkj f

</p><asp:XmlDataSourceID="Data"runat="server"><Data><items><itemid="1"name="ASP.NET"url="http://msdn.microsoft.com"/><itemid="2"name="AJAX"url="http://ajax.asp.net"/><itemid="3"name="AJAX Control Toolkit"url="http://ajax.asp.net/ajaxtoolkit"/></items></Data></asp:XmlDataSource><!-- If you start the UpdatePanel here, clicking the links won't work -->

<!-- Databound list of LinkButtons that fire server side Command events passing in their ID --><asp:DataListID="List"runat="server"DataSourceID="Data"><HeaderTemplate>Microsoft Web Development Technologies:</HeaderTemplate><ItemTemplate><asp:LinkButtonID="CommandButton"runat="server"Text='<%# Eval("name") %>'CommandName="Select"CommandArgument='<%# Eval("id") %>'OnCommand="CommandButton_OnSelect"/></ItemTemplate></asp:DataList><!-- If you start the UpdatePanel here, you need some ControlID for the trigger.

Try CommandButton and you get an error that it doesn't exit.

Try List and the popup doesn't show.

What else?!

You can set it to something totally unrelated, like btnTest for the popup to work

or you can remove the UpdatePanel altogether, since it's no good anyways...

-->

<asp:UpdatePanelID="UPPnl"runat="Server"UpdateMode="Conditional"><ContentTemplate><asp:PanelID="Panel1"runat="server"width=630CssClass="modalPopup"style="display:none">

<asp:LabelID="myDynamicLabel"runat="server"></asp:Label>

<asp:ButtonCssClass="command"ID="Cancel"runat="server"Text="Cancel"CausesValidation="False"/></asp:Panel></ContentTemplate><Triggers><asp:AsyncPostBackTriggerControlID="btnTest"/></Triggers></asp:UpdatePanel>

<ajaxToolkit:ModalPopupExtenderID="ModalPopupExtender"runat="server"TargetControlID="btnTest"PopupControlID="Panel1"BackgroundCssClass="modalBackground"DropShadow="true"OkControlID="Cancel"CancelControlID="Cancel"/><br/><br/><asp:ButtonID="btnTest"runat="server"Text="Don't Click Me!"/></form>

</

body>

</

html>


David,

I don't know if you finally got the sample you needed or not. But so you know, I do have the latest update to the toolkit. However I can't get the modalpopup and updatepanel to work together properly. And that's not to mention the funny issue of the popup sometimes showing up automatically and without being triggered from the code. I saw others had that problem, too.

Anyways, here is a self-contained test page for you. It is based on some code initiallyborrowedfrom Ted Glaza, changed to VB, then AJAX, then simplified and then changed to fit this sample! :)

Any solution or workaround you can provide me with, is highly appreciated. I'm already in a time crunch and don't have the luxury of playing around with these controls. By the way, in real life,my popup control has to be launched from imagebuttons in a DataGrid. All are created on the server-side and I can't change that design easily.

Thanks,

Kathy

<%

@.PageLanguage="VB" %>

<%

@.RegisterAssembly="AjaxControlToolkit"Namespace="AjaxControlToolkit"TagPrefix="ajaxToolkit" %>

<!

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

<

scriptrunat="server">ProtectedSub CommandButton_OnSelect(ByVal senderAsObject,ByVal eAs CommandEventArgs)Dim IDAsInteger =CInt(e.CommandArgument)Dim xAs System.Xml.XmlNode = Data.GetXmlDocument.SelectSingleNode(String.Format("descendant::item[@.id='{0}']", ID))IfNot IsNothing(x)Then

myDynamicLabel.Text =

"The URL is: " & x.Attributes("url").ValueElse

myDynamicLabel.Text =

"Item with ID: " & ID.ToString &" could not be found."EndIf

ModalPopupExtender.Show()

EndSub

</

script>

<

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

<

headrunat="server"><title>Untitled Page</title><styletype="text/css">

/*Modal Popup*/

.modalBackground

{background-color:Gray;filter:alpha(opacity=70);opacity:0.7;

}

.modalPopup

{background-color:#FFF8C6;border-width:3px;border-style:solid;border-color:Gray;padding:3px;width:350px;

}

</style>

</

head>

<

body><formid="form1"runat="server"><asp:ScriptManagerID="ScriptManager1"runat="server"EnablePartialRendering=true/><p>

Some nonsense text to show the postback. blah di blah.

kjdhfjkh ksdhhsdfhj haunnsdju urfh kjhdjkf kjhdflgkh hr ujseopop';ui;j m[plio;l hjyryawre ghvnb mdfb jyutet ihe lijj huhiut hiuhvnmx mnbuyteruy gwerbmbnhfghtf jhel/krtjk ih banvdhtsfr cvnhfhtfd wklieth bnhdchzgf dejhfgkuhgr jwhg

lusyfiuysdkj jutyujefg jgdfjhg hjdgfhjg dkjf jkhgdsf uytser bvioy yhsejehyj mjnbcvjytyue rvkiuyd h j vihbrtkj f

</p><p>

Some nonsense text to show the postback. blah di blah.

kjdhfjkh ksdhhsdfhj hak kkfguhe mndfgkjh dkjg hzsnmbrtulk typi ,bngf aytwr eb mbhjvu ;orijnjm BFMhbmhdfbv ghvme hjmhg fbmbmnb mnbz

unnsdju urfh lusyfiuysdkj jutyujefg jgdfjhg hjdgfhjg dkjf jkhgdsf uytser bvioy yhsejehyj mjnbcvjytyue rvkiuyd h j vihbrtkj f

</p><p>

Some nonsense text to show the postback. blah di blah.

kjdhfjkh ksdhhsdfhj haunnsdju urfh lusyfiuysdkj jutyujefg jgdfjhg hjdgfhjg dkjf jkhgdsf uytser bvioy yhsejehyj mjnbcvjytyue rvkiuyd h j vihbrtkj f

</p><asp:XmlDataSourceID="Data"runat="server"><Data><items><itemid="1"name="ASP.NET"url="http://msdn.microsoft.com"/><itemid="2"name="AJAX"url="http://ajax.asp.net"/><itemid="3"name="AJAX Control Toolkit"url="http://ajax.asp.net/ajaxtoolkit"/></items></Data></asp:XmlDataSource><!-- If you start the UpdatePanel here, clicking the links won't work -->

<!-- Databound list of LinkButtons that fire server side Command events passing in their ID --><asp:DataListID="List"runat="server"DataSourceID="Data"><HeaderTemplate>Microsoft Web Development Technologies:</HeaderTemplate><ItemTemplate><asp:LinkButtonID="CommandButton"runat="server"Text='<%# Eval("name") %>'CommandName="Select"CommandArgument='<%# Eval("id") %>'OnCommand="CommandButton_OnSelect"/></ItemTemplate></asp:DataList><!-- If you start the UpdatePanel here, you need some ControlID for the trigger.

Try CommandButton and you get an error that it doesn't exit.

Try List and the popup doesn't show.

What else?!

You can set it to something totally unrelated, like btnTest for the popup to work

or you can remove the UpdatePanel altogether, since it's no good anyways...

-->

<asp:UpdatePanelID="UPPnl"runat="Server"UpdateMode="Conditional"><ContentTemplate><asp:PanelID="Panel1"runat="server"width=630CssClass="modalPopup"style="display:none">

<asp:LabelID="myDynamicLabel"runat="server"></asp:Label>

<asp:ButtonCssClass="command"ID="Cancel"runat="server"Text="Cancel"CausesValidation="False"/></asp:Panel></ContentTemplate><Triggers><asp:AsyncPostBackTriggerControlID="btnTest"/></Triggers></asp:UpdatePanel>

<ajaxToolkit:ModalPopupExtenderID="ModalPopupExtender"runat="server"TargetControlID="btnTest"PopupControlID="Panel1"BackgroundCssClass="modalBackground"DropShadow="true"OkControlID="Cancel"CancelControlID="Cancel"/><br/><br/><asp:ButtonID="btnTest"runat="server"Text="Don't Click Me!"/></form>

</

body>

</

html>


Kathy,

You seem to be trying to do dynamic population. If so, then I'd recommend the approach I blog here:http://blogs.msdn.com/delay/archive/2006/09/19/762609.aspx.

Alternatively, if you're willing to have slightly larger pages, the below is your sample transformed into a solution that doesn't use postbacks and therefore doesn't need UpdatePanels:

<%@. Page Language="VB" %><%@. Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxToolkit" %><!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> <style type="text/css"> /*Modal Popup*/.modalBackground{ background-color:Gray; filter:alpha(opacity=70); opacity:0.7; }.modalPopup{ background-color:#FFF8C6; border-width:3px; border-style:solid; border-color:Gray; padding:3px; width:350px; } </style></head><body> <form id="form1" runat="server"> <asp:ScriptManager ID="ScriptManager1" runat="server" EnablePartialRendering="true" /> <p> Some nonsense text to show the postback. blah di blah. kjdhfjkh ksdhhsdfhj haunnsdju urfh kjhdjkf kjhdflgkh hr ujseopop';ui;j m[plio;l hjyryawre ghvnb mdfb jyutet ihe lijj huhiut hiuhvnmx mnbuyteruy gwerbmbnhfghtf jhel/krtjk ih banvdhtsfr cvnhfhtfd wklieth bnhdchzgf dejhfgkuhgr jwhg lusyfiuysdkj jutyujefg jgdfjhg hjdgfhjg dkjf jkhgdsf uytser bvioy yhsejehyj mjnbcvjytyue rvkiuyd h j vihbrtkj f </p> <p> Some nonsense text to show the postback. blah di blah. kjdhfjkh ksdhhsdfhj hak kkfguhe mndfgkjh dkjg hzsnmbrtulk typi ,bngf aytwr eb mbhjvu ;orijnjm BFMhbmhdfbv ghvme hjmhg fbmbmnb mnbz unnsdju urfh lusyfiuysdkj jutyujefg jgdfjhg hjdgfhjg dkjf jkhgdsf uytser bvioy yhsejehyj mjnbcvjytyue rvkiuyd h j vihbrtkj f </p> <p> Some nonsense text to show the postback. blah di blah. kjdhfjkh ksdhhsdfhj haunnsdju urfh lusyfiuysdkj jutyujefg jgdfjhg hjdgfhjg dkjf jkhgdsf uytser bvioy yhsejehyj mjnbcvjytyue rvkiuyd h j vihbrtkj f </p> <asp:XmlDataSource ID="Data" runat="server"> <Data> <items> <item id="1" name="ASP.NET" url="http://msdn.microsoft.com" /> <item id="2" name="AJAX" url="http://ajax.asp.net" /> <item id="3" name="AJAX Control Toolkit" url="http://ajax.asp.net/ajaxtoolkit" /> </items> </Data> </asp:XmlDataSource> <asp:DataList ID="List" runat="server" DataSourceID="Data"> <HeaderTemplate> Microsoft Web Development Technologies:</HeaderTemplate> <ItemTemplate> <asp:LinkButton ID="CommandButton" runat="server" Text='<%# Eval("name")%>' CommandName="Select" CommandArgument='<%# Eval("id")%>'/> <ajaxToolkit:ModalPopupExtender ID="ModalPopupExtender" runat="server" TargetControlID="CommandButton" PopupControlID="Panel1" BackgroundCssClass="modalBackground" DropShadow="true" OkControlID="Cancel" CancelControlID="Cancel" /> <asp:Panel ID="Panel1" runat="server" Width="630" CssClass="modalPopup" Style="display: none"> <asp:Label ID="myDynamicLabel" runat="server" Text='<%# Eval("url")%>'></asp:Label> <asp:Button CssClass="command" ID="Cancel" runat="server" Text="Cancel" CausesValidation="False" /> </asp:Panel> </ItemTemplate> </asp:DataList> </form></body></html>

Sorry, for my bad english. Maybe this is the solution for some...

This is a part of a code of ASCX user control in C# and works

....

<asp:UpdatePanel ID="updDatos" runat="server" UpdateMode="Conditional">
<ContentTemplate>

<%--CONTROL USER (Not important)... --%>
<delta:filtro ID="Filtro" runat="server" />

<br />

<asp:Button runat="server" ID="btnBuscar" OnClick="btnBuscar_Click" Text="Buscar" />

<%--1. CONTROL USERYes--%>
<delta:resultado ID="Resultado" runat="server" OnSeleccionar="Seleccionar_Click"/
<%--2. Button invisible ...Yes --%>
<div style="display:none">
<asp:LinkButton ID="btnPrevio" runat="server" Text="Any text... " />
</div>

<asp:Panel ID="pnlConfirma" runat="server" CssClass="modalPopup" Style="display: none">
<asp:Panel ID="Panel3" runat="server" Style="cursor: move; background-color: #DDDDDD;
border: solid 1px Gray; color: Black">
<div>
<p>
De aca arrastro...</p>
</div>
</asp:Panel>
<asp:Label ID="lblConfirmacion" runat="server" />
<br />
<asp:Button ID="btnOk" runat="server" Text="Ok" />
<asp:Button ID="btnCancelar" runat="server" Text="Cancelar" />
</asp:Panel>


<ajax:ModalPopupExtender ID="modalConfirmar" runat="server" BackgroundCssClass="modalBackground"
CancelControlID="btnCancelar" DropShadow="true" OkControlID="btnOK" PopupControlID="pnlConfirma"
PopupDragHandleControlID="Panel3" TargetControlID="btnPrevio">
</ajax:ModalPopupExtender
</ContentTemplate>
<Triggers>

<%--3. Trigger of my control userYes--%>
<asp:AsyncPostBackTrigger ControlID="Resultado" EventName="Seleccionar" />

<%--4. IMPORTANT: Trigger of Invisible ButtonGeeked--%>
<asp:AsyncPostBackTrigger ControlID="btnPrevio" EventName="Click" />
</Triggers>
</asp:UpdatePanel>

.........................................................

in code:

protected voidSeleccionar_Click(object sender, EventArgs e) {

//BLA BLA BLA...

//personalize my modal pop up, previously... (bad englishStick out tongue)
lblConfirmacion.Text ="Personalizar el control..."; //Text personalized..

//The event of my control user... trigger the modal pop up...
modalConfirmar.Show();
//BLA BLA BLA...

}

Smile