Showing posts with label control. Show all posts
Showing posts with label control. Show all posts

Wednesday, March 28, 2012

Multiple Popups using popcontrol extender

In the previous version of the ajax control toolkit I could reference multiply popups with one control. Ie on the page I have one calendar and 10 different textboxs which call popup the same calendar control. This would then run the selection changed code for the calendar and commit the date to which ever control had opened the popup. ie

ProtectedSub Date_Selector_SelectionChanged(ByVal senderAsObject,ByVal eAs System.EventArgs)Handles Date_Selector.SelectionChanged

Date_Popup.Commit(Date_Selector.SelectedDate.ToShortDateString)

EndSub

However with the new version of the toolkit you have to have a different popup for each textbox. So when it goes into the date selector section how do I chosse the right popup to send the data back to.

I think the test case in ToolkitTests\Manual\Repeater.aspx shows how to do this the new way.

I had asimilar problemTed Glaza helped me solve. I have two textboxes with a popupcontrolextender attached to each, both of which call a single calendar, cal1. Some code snippits:

Code behind:

Protected Sub Cal1_SelectionChanged(ByVal senderAs Object,ByVal eAs System.EventArgs)Handles Cal1.SelectionChangedDim tmppceAs AjaxControlToolkit.PopupControlExtender tmppce = AjaxControlToolkit.PopupControlExtender.GetProxyForCurrentPopup(Page) tmppce.Commit(Cal1.SelectedDate)End Sub

Declaration on the top of the .aspx page:

<%@. Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="act" %>
 
Everything works as expected. One thing to note, I'm running a self-compiled version of the toolkit - 9854. 

Multiple update panels

I had a query regarding multiple update panels.
I have a user control which contains one update panel.This user control contains a hidden textbox .
I am updating the updatepanel on basis of a timer control in javascripts which raises a postback.

I have placed two instances of this user control in another page say for eg. CIndexPage.aspx.
Now the Script manager is also placed in the same page ie CIndexPage.aspx.

Will the two updatepanels wrk independently.

Is the hidden variable shared between the instances of the update panel ?
Becoz the issue here is that even if i pass a value for the hidden textbox contained
in the first Update Panel, still the value gets stored for the hidden
variable in the second instance of the updatePanel.

Can we use Update Panels in a User Control and place multiple instances of the UserControls in a page.

Please if someone cld help me with this.

Thanks in advance.

Regards,
Shweta

hello.

well, the updatepanels will work independently. if you want to get independent refershes, you need to make sure that you've set the update mode of the pannel to conditional.

regarding the hidden field, it depends on how you've injected in the page...


Hi,

My Code is somewhat like this

User Control contains

_____________________________________________________________

<asp:UpdatePanel id=UpdatePanel1 runat=server>
<div id=DivCtrl runat=server >
<asp:HiddenField runat="server" ID="RequestID" Value="0" />
</UpdatePanel>


____________________________________________________________________
There is adiv control which contains multiple hyperlinks.That is done thru .cs file of the Master Control and is dynamically generated.
The hidden filed in placed inside the UpdatePanel and the RequestID is updated on the hyperlink click.

And 2 instances of this user control are placed in the Parent Page.
Also what happens is even though i am clicking on the first User Controls hyperlink (first updatepanel) still the Value is assigned to the second User Controls Hidden Field.

It always updates the last user control.

Why does work in this manner . Also to update the UpdatePanel i am using the timer control and _dopostback method.

Is there an issue with the timer control.Shld that be placed in the ParentPage.

regards,

Shweta


hello.

can you please build a small demo app with a simple user control + page and put it here?


yes sure
------------
User Control Code is as follows for .aspx is as follows
-------------
<script language =javascript>
var l_objtimer="";
l_objtimer =window.setInterval('UPdatePanel',1000);
function UPdatePanel()
{
var obj=get$('<%=RequestID.ClientID%>');
_dopostback("obj",'');
}

function CallDetails(nSerialNo)
{
var obj=get$('<%=RequestID.ClientID%>');
obj.value=nSerialNo;
_dopostback("obj",'');
}
</script>
<body>
<asp:UpdatePanel id=UpdatePanel1 runat=server>
<div id=DivCtrl runat=server >
<asp:HiddenField runat="server" ID="RequestID" Value="0" />
</UpdatePanel>
</body>

------------
end
-------------

------------
User Control Code is as follows for cs is as follows
-------------

In this i dynamically adding a hyperlink whose onclick events call CallDetails(nSerialNo) (in .aspx of user control).
And pass different value to the nSerialNo parameter on the click event.In the event i change the value of RequestID to the the nSerialNo.

------------
end
-------------

------------
Parent Page Code is as follows for .aspx is as follows
-------------
<%@. Register TagPrefix="csc" Namespace="CustomServerControls" %>
<body>
<asp:ScripManager runat=server id=ScriptMgr1 >
</asp:ScripManager >
<csc:CustomServerControls id=CustomServer1 runat=server >
</csc:CustomServerControls>

<csc:CustomServerControls id=CustomServer2 runat=server >
</csc:CustomServerControls>

</body>

------------
end
-------------

This way 2 instances of this user control are placed in the Parent Page.
Also what happens is even though i am clicking on the first User Controls hyperlink (first updatepanel) still the Value is assigned to the second User Controls Hidden Field.

Also if i am placing the usercontrol in a page and call the page thru <script tag by specifying the source it gives me a Syntax error.

Can i call the page in this way.


hello

well, now it's clear!. what you shoud do is change the js code. you should have something like this:

<script language =javascript>
var l_objtimer="";
l_objtimer =window.setInterval('UPdatePanel',1000);
function UPdatePanel(idCtl)
{
var obj=get$(idCtl);
_dopostback("obj",'');
}

function CallDetails(idCtl, nSerialNo)
{
var obj=get$(idCtl);
obj.value=nSerialNo;
_dopostback("obj",'');
}
</script>

where idCtl is the ID of the control (hidden field) you want to use. yep, you'll have to change your code so that it also passes the id of the field when you call the method.

in your code, what's happening is that when you're adding the second user control, it'll add the js methods again, overriding the previous definitions. this means that clicking on the 1st or 2nd user control will always call the latest definition, which points to the id of the last user control you've added to the page. if you perform the changes I've said, this won't happen any more.

Multiple Update Panel Animation Extenders on one page

Hi there!

I'm developing a web user control that contains an Update Panel and uses an Update Panel Animation Extender.
The animation is quite simple: while the panel is updating, it fades out the contents of the update panel and fades in the "please wait while processing..." message...then the animation reverses the process when the panel is Updated. The animation works quite nicely.

The problem I'm facing is when I have more than one of these web user controls on the page at a time (I'm using 8 of these on one page at a time).
If one web user control's update panel does an asynchronous postback, all of the animations are run!

Does anyone know how to get around this problem?

Thanks in advance,

-Frinny

Hi,

Would you please provide with any code of ypur usercontrol?

Or create a simple repro of this problem?

Thanks,


I forgot that I had posted this question.
I found the solution to my problem a while ago.

The problem I was describing is not actually a problem, it is how the UpdatePanelAnimationExtender works.

Anyways, to get around this problem I ended up using regular Animations instead of the UpdatePanelAnimationExtender.

Cheers!

Multiple Update Panels & Control Events

Thankfully i've been able to re-create this issue but i'm still not entirely sure why it happens as it does. I've created a page with two update panels, inside of each is a label and a button. Each label is set to the current date when the labels PreRender event fires. The first time this loads, each event fires at pretty much the same time. As expected if i press either of the buttons, both label PreRender events fire and update the corresponding label. However If i set the update mode to conditional on the updatepanel, both labels PreRender events fire but only the one which shares the update panel with the pressed button has the UI updated. In this trivial example thats not too much of a problem, however when I'm loading in a dataset in one of the panels, i dont want the data being re-loaded in each time a different update panel posts back. Thanks in advance, Matt Here's my trivial example HTML and C# c#
protected void Page_Load(object sender, EventArgs e) { }protected void Label1_PreRender(object sender, EventArgs e) { Label1.Text = DateTime.Now.ToString(); }protected void Label2_PreRender(object sender, EventArgs e) { Label2.Text = DateTime.Now.ToString(); }protected void Button2_Click(object sender, EventArgs e) { }protected void Button1_Click(object sender, EventArgs e) { }
<asp:ScriptManager ID="ScriptManager1" runat="server" /> <div> <asp:UpdatePanel ID="UpdatePanel1" runat="server" UpdateMode="Conditional"> <ContentTemplate> <asp:Label ID="Label2" runat="server" OnPreRender="Label2_PreRender" Text="Label"></asp:Label> <asp:Button ID="Button1" runat="server" OnClick="Button1_Click" Text="Submit 2" /> </ContentTemplate> </asp:UpdatePanel> </div> <asp:UpdatePanel ID="UpdatePanel2" runat="server" UpdateMode="Conditional"> <ContentTemplate> <asp:Label ID="Label1" runat="server" OnPreRender="Label1_PreRender" Text="Label"></asp:Label> <asp:Button ID="Button2" runat="server" OnClick="Button2_Click" Text="Submit One" /> </ContentTemplate> </asp:UpdatePanel>

This is by design. When you have multiple UpdatePanels and each set to Conditional, UI updates only occur in that particular UpdatePanel. You can get more info about UpdatePanels in the docs:http://www.asp.net/AJAX/Documentation/Live/tutorials/UpdatePanelTutorials.aspx

For updating a label like you are, I would utilize PageMethods vs. and UpdatePanel anyway. You can mix the two technologies if you need to. Seehttp://encosia.com/2007/07/11/why-aspnet-ajax-updatepanels-are-dangerous for an excellent example and more information.

-Damien

Multiple UpdatePanels in Wizard with MasterPage does not work.

I've exhausted my resources on this and still haven't found an answer. I'm trying to use the UpdatePanel with a Wizard control who's page is using a MasterPage. If I use more then one UpdatePanel at a time I get a "javascript runtime error: Object Required" Here's what I have tried:

    Using ScriptManagerProxy on the content page in addition to the ScriptManager that's in the MasterPage. Results = No effect.Stripping all javascript from both the MasterPage and The Content page. Results =No effectRemoving all comments. Results = No effect.Wrapping the entire Wizard in a UpdatePanel. Results = Not a good solution. My Wizard has 11 steps and at anytime during the steps if the user selects back on the browser it takes them completly out of the Wizard. Imagine how frustrating that would be in a Order process.Removed the page association to the Wizard. Results = Works but it's not a good solution as I lose the functionality of the MasterPage.When I use one UpdatePanel anywhere within the Wizards steps it works properly. It's only when I try to add a second Panel that I get the javascript error.Double checked my Atlas installation and files dates , sizes etc. Results = All files are correct.Searched the web for a possible solution. Results= Not a dam thing.Posted this message hereResults = TBD

I'm using VS 2005 and the March CPT release of Atlas.

hello.

this is problem related with the way the wizard control works. the problem is that the callback gets all the panels and the html only returns the visible one (so, if you have 3 panels, the wizard returns the one that is visible according with the current step, but due to the way that the callback mechanism works, you'll get all the other panels too and the client side of atlas will try to refresh those elements and this will trigger the error you're having).

to solve this, set the mode of all the updatepanels to condition. here's a demo page:

<%

@.PageLanguage="C#" %>

<!

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

<

scriptrunat="server">void P(object sender,EventArgs args)

{

if (sender == info1)

{

t1.Text = info1.Text;

}

elseif (sender == info2)

{

t2.Text = info2.Text;

}

else

t3.Text = info3.Text;

}

</

script>

<

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

<

headrunat="server"><title>Untitled Page</title>

</

head>

<

body><formid="form1"runat="server"><atlas:ScriptManagerrunat="server"ID="man"EnablePartialRendering="true"></atlas:ScriptManager><asp:Wizardrunat="server"ID="ma"><WizardSteps><asp:WizardStep><atlas:UpdatePanelrunat="server"ID="Pan1"Mode="Conditional"><ContentTemplate><asp:TextBoxrunat="server"ID="info1"OnTextChanged="P"AutoPostBack="true"/><br/><asp:Literalrunat="server"ID="t1"/></ContentTemplate></atlas:UpdatePanel></asp:WizardStep><asp:WizardStep><atlas:UpdatePanelrunat="server"ID="UpdatePanel1"Mode="Conditional"><ContentTemplate><asp:TextBoxrunat="server"ID="info2"OnTextChanged="P"AutoPostBack="true"/><br/><asp:Literalrunat="server"ID="t2"/></ContentTemplate></atlas:UpdatePanel></asp:WizardStep><asp:WizardStep><atlas:UpdatePanelrunat="server"ID="UpdatePanel2"Mode="Conditional"><ContentTemplate><asp:TextBoxrunat="server"ID="info3"OnTextChanged="P"AutoPostBack="true"/><br/><asp:Literalrunat="server"ID="t3"/></ContentTemplate></atlas:UpdatePanel></asp:WizardStep></WizardSteps></asp:Wizard></form><scripttype="text/javascript"src="Atlas.js"></script>

</

body>

</

html>

Hi Luis,

That worked beautifully, thank you very much! I remeber trying mode="Conditional" however I think I probably didn't set all the panels as I should have.

On a related note, I turned the step buttons into templates so I could have more freedom on placement. I'm also setting the ActiveStepIndex in the codebehind instead of using CommandName. If I wrap those buttons with the UpdatePanel they lose their ability to step, it's like they are ignoring the ActiveStepIndex or I get the JavaScript error. It would be nice to be able to include these step buttons in the UpdatePanel. On the credit card confirmation step it can take several seconds for a response and providing the progress indicator pretty much ensures the user will wait.

Is this also related to the way the wizard callback mechanisum works?


hello again.

hum...not sure on that...can you change the previous page i've posted so that it uses your templates for the step buttons? i'm a little busy now and if you'd change that page i'd be able to take 5 mins and try to understand what's going on...


Hi Luis,

I used your example and modified it to show you the behavior. I did put it in VB and pasted it below. If you will notice I have two rows of buttons. The first row are buttons inside the update panel. They set the active step in the code behind. The second set is the button templates for the wizard. Clicking the first row buttons just causes a post back. Although when you click the second row next button after clicking the first row next button the page jumps to step 3. So for some reason the index is changing but the actual step is not displaying. Also another strange behavior I observed with my existing project is when I uplaoded the new aspx files with the update panel to my isp's server, the page is actualy refreshing on updates where as it does not when I run it on my localHost. Not sure why this is occuring. I understand your busy and if you think I should repost the last issue in a new thread, I will. Just thought I would mention it here.

Thanks,

Jason

testnm.aspx:

<%

@.PageLanguage="VB"AutoEventWireup="false"CodeFile="testnm.aspx.vb"Inherits="testnm"title="Untitled Page" %>

<!

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

<

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

<

headrunat="server">

<

title>Untitled Page</title>

</

head>

<

body>

<

formid="form2"runat="server">

<

atlas:ScriptManagerrunat="server"ID="man"EnablePartialRendering="true">

</

atlas:ScriptManager>

<

asp:Wizardrunat="server"ID="ma"ActiveStepIndex="0">

<

WizardSteps>

<

asp:WizardSteprunat="server">

<

atlas:UpdatePanelrunat="server"ID="Pan1"Mode="Conditional">

<

ContentTemplate>

<

asp:TextBoxrunat="server"ID="info1"AutoPostBack="true"/>

<

br/>

<

asp:Literalrunat="server"ID="t1"/><br/><br/><asp:ButtonID="StartNextButton1"runat="server"Text="Next"/><br/>

</

ContentTemplate>

</

atlas:UpdatePanel>

</

asp:WizardStep>

<

asp:WizardSteprunat="server">

<

atlas:UpdatePanelrunat="server"ID="UpdatePanel1"Mode="Conditional">

<

ContentTemplate>

<

asp:TextBoxrunat="server"ID="info2"AutoPostBack="true"/>

<

br/>

<

asp:Literalrunat="server"ID="t2"/><br/><br/><asp:ButtonID="StepPreviousButton1"runat="server"CausesValidation="False"Text="Previous"OnClick="StepPreviousButton1_Click"/><asp:ButtonID="StepNextButton1"runat="server"Text="Next"/><br/>

</

ContentTemplate>

</

atlas:UpdatePanel>

</

asp:WizardStep>

<

asp:WizardSteprunat="server">

<

atlas:UpdatePanelrunat="server"ID="UpdatePanel2"Mode="Conditional">

<

ContentTemplate>

<

asp:TextBoxrunat="server"ID="info3"AutoPostBack="true"OnTextChanged="info3_TextChanged"/>

<

br/>

<

asp:Literalrunat="server"ID="t3"/><br/><br/><asp:ButtonID="FinishPreviousButton1"runat="server"CausesValidation="False"Text="Previous"OnClick="FinishPreviousButton1_Click"/><asp:ButtonID="FinishButton1"runat="server"CommandName="MoveComplete"Text="Finish"/><br/>

</

ContentTemplate>

</

atlas:UpdatePanel>

</

asp:WizardStep>

</

WizardSteps><StartNavigationTemplate><asp:ButtonID="StartNextButton"runat="server"CommandName="MoveNext"Text="Next"/></StartNavigationTemplate><StepNavigationTemplate><asp:ButtonID="StepPreviousButton"runat="server"CausesValidation="False"CommandName="MovePrevious"Text="Previous"/><asp:ButtonID="StepNextButton"runat="server"CommandName="MoveNext"Text="Next"/></StepNavigationTemplate><FinishNavigationTemplate><asp:ButtonID="FinishPreviousButton"runat="server"CausesValidation="False"CommandName="MovePrevious"Text="Previous"/><asp:ButtonID="FinishButton"runat="server"CommandName="MoveComplete"Text="Finish"/></FinishNavigationTemplate><NavigationStyleHorizontalAlign="Left"/>

</

asp:Wizard>

</

form>

<

scripttype="text/javascript"src="scriptlibrary\atlas\debug\Atlas.js"></script>

</

body>

</

html>

testnm.asxp.vb:

Partial

Class testnmInherits System.Web.UI.PageProtectedSub info1_TextChanged(ByVal senderAsObject,ByVal eAs System.EventArgs)Handles info1.TextChanged

t1.Text = info1.Text

EndSubProtectedSub info2_TextChanged(ByVal senderAsObject,ByVal eAs System.EventArgs)Handles info2.TextChanged

t2.Text = info2.Text

EndSubProtectedSub info3_TextChanged(ByVal senderAsObject,ByVal eAs System.EventArgs)Handles info3.TextChanged

t3.Text = info3.Text

EndSubProtectedSub StartNextButton1_Click(ByVal senderAsObject,ByVal eAs System.EventArgs)Handles StartNextButton1.Click

ma.ActiveStepIndex = 1

EndSubProtectedSub StepNextButton1_Click(ByVal senderAsObject,ByVal eAs System.EventArgs)Handles StepNextButton1.Click

ma.ActiveStepIndex = 2

EndSubProtectedSub StepPreviousButton1_Click(ByVal senderAsObject,ByVal eAs System.EventArgs)Handles StepPreviousButton1.Click

ma.ActiveStepIndex = 0

EndSubProtectedSub FinishPreviousButton1_Click(ByVal senderAsObject,ByVal eAs System.EventArgs)Handles FinishPreviousButton1.Click

ma.ActiveStepIndex = 1

EndSub

End

Class

hello.

though i just galnce at it, i'd say that this is the expected behavior. when a control placed inside the updatepanel generates a postback, the content of that panel is sent back to the client. so, the problem is that you're changing the updatepanel, but the scriptmanager is getting the content of the panel that caused the postback. i haven't seen if there's a workaround for this issue...


Hey Luis,

Its curious that it works if you wrap the entire wizard in the UpdatePanel. If I knew then what I know now, I wouldn't have used the Wizard.

Thanks for the help.

Jason

Monday, March 26, 2012

Multiview and Javascript in a view.

Hi, I am using a Multiview control in an update panel, and I need to output some dynamic Javascript inside a View control. Please see below.

<%@dotnet.itags.org. Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %>

<!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">
<asp:ScriptManager ID="ScriptManager1" runat="server" />
<asp:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:Panel ID="Panel1" runat="server" Height="478px" Width="557px">
<asp:MultiView ID="MultiView1" runat="server" ActiveViewIndex="0">
<asp:View ID="View1" runat="server">


</asp:View>
<asp:View ID="View2" runat="server">

<script type="text/Javascript">//<![CDATA[
function aa(){alert('<%= DateTime.Now %>');}
//]]></script>
<input type='button' onclick='aa()' />

</asp:View>
</asp:MultiView>
<asp:Button ID="Button2" runat="server" OnClick="Button2_Click" Text="Button" /></asp:Panel>
</ContentTemplate>
</asp:UpdatePanel>
</form>
</body>
</html>

--BEHIND--

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 partial class Default2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{

}
protected void Button2_Click(object sender, EventArgs e)
{
MultiView1.SetActiveView(View2);
}
}

The problem is, that when you click the button that runs the function "aa", an "Object expected" error is thrown. Presumably because the newly outputted script has not been 'registered' with the browser (I checked with Nikhils Web Dev Helper and the script is present).

As I say, the script is dynamic, so I can't move it to an external file, nor would it be good to have to write the script outside of the Multiview (since it's dependent on the controls in View).

Any help or tips greatly welcome - thanks,

Jim


Read this, will give you solution.

http://forums.asp.net/thread/1502486.aspx

WS


Thanks, that did help with my example -however...

In reality my UpdatePanel and Multiview are inside a UserControl. So I dont have access to ScriptManager from the UserControl.

I looked at ScriptManagerProxy, but that doesn't have the RegisterClientScriptBlock method :(

Any idea how I can do this from within a UserControl?

Many thanks

Jim


Is this your code behind from your UserControl?

protected void Button2_Click(object sender, EventArgs e)
{
MultiView1.SetActiveView(View2);
}

??

You can add

protected void Button2_Click(object sender, EventArgs e)
{
MultiView1.SetActiveView(View2);
System.Web.UI.ScriptManager.RegisterClientScriptBlock ...
}

It works on my end ... should be the same on yours.

WS


AHH! RegisterClientScriptBlock is static - sorry I assumed it wasn't.

Yes that works great, thanks very much - you saved me some awkward workarounds.

Smile

Jim


Can I open up this topic, and add a little twist to it?

I have u panel inside a multiview, this panel has a usercontrol which shows a HTML page from a database (response.binarywrite because it's all blobs) I hav e NO control of the javascript that is used in the HTML files that are loaded from the database.

One of the HTML files that is loaded, contains javascript to have a menu with hoverfunctions enabled on the html-page:

if (window.attachEvent) window.attachEvent("onload", sfHover);

When I switch the multiview.activeindex, back and forth to the panel with the usercontrol, the hover functions do not work anymore...anyway, in IE they don't. In Firefox they do work.

The RegisterClientScriptBlock is no option, because I am not aware of the javascript functions that are used in the database-files.

I hope my explanation is clear...

Rob

Multiview control

Hi.

I used three radio button to switch among multiview control, how may I include AJAX into radio button control, so it doesn't post back when I try to change view ? I tried, it doesn't seem to work.

thanks for the help.

Hi,

You can avoid the postback by wrapping them in an UpdatePanel. For instance:

<%@. 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 RadioButtonList1_SelectedIndexChanged(object sender, EventArgs e) { MultiView1.ActiveViewIndex = RadioButtonList1.SelectedIndex; }</script><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:RadioButtonList ID="RadioButtonList1" runat="server" AutoPostBack="True" OnSelectedIndexChanged="RadioButtonList1_SelectedIndexChanged"> <asp:ListItem>1</asp:ListItem> <asp:ListItem>2</asp:ListItem> <asp:ListItem>3</asp:ListItem> </asp:RadioButtonList> <asp:MultiView ID="MultiView1" runat="server"> <asp:View ID="View1" runat="server"> View1</asp:View> <asp:View ID="View2" runat="server"> View2</asp:View> <asp:View ID="View3" runat="server"> View3</asp:View> </asp:MultiView> </ContentTemplate> </asp:UpdatePanel> </form></body></html>
Hope this helps.

thanks.

But, I don't understand, in the radio button, it says AutoPostBack=true. I did exactl the way you did except put radio button in the updatepanel, what is the magic for this updatepanel ?

thanks so much for the help.


That's weird. Can you show me your page?


Hi. this is my code.

<divstyle="border-bottom:dotted; border: 1px;">

<asp:MultiViewid="MultiView1"runat="server"ActiveViewIndex="0">

<asp:ViewID="View1"runat="server">

<asp:LabelID="lblMsg"runat="server"Width="273px"Font-Bold="True"ForeColor="Red"></asp:Label><br/>

<asp:TextBoxID="txtAddress"runat="server"></asp:TextBox>

<asp:LabelID="Label2"runat="server"Text="Ex. 101 Monroe St"Width="111px"></asp:Label><br/>

<asp:TextBoxID="txtZip"runat="server"></asp:TextBox>

<asp:LabelID="Label3"runat="server"Text="Ex. 20850"Width="106px"></asp:Label><br/>

<asp:TextBoxID="txtMiles"runat="server">2</asp:TextBox>

<asp:LabelID="Label4"runat="server"Text="Within Miles"Width="107px"></asp:Label><br/>

<asp:ButtonID="btnAddress"runat="server"Text="Find"OnClick="btnAddress_Click"/>

</asp:View>

<asp:ViewID="View2"runat="server">

<asp:DropDownListID="lstCities"runat="server"></asp:DropDownList><br/>

<asp:ButtonID="btnCities"runat="server"Text="Find"OnClick="btnCities_Click"/>

</asp:View>

<asp:ViewID="View3"runat="server">

<asp:DropDownListID="lstZipCode"runat="server">

</asp:DropDownList>

<asp:ButtonID="btnZip"runat="server"Text="Find"OnClick="btnZip_Click"/>

</asp:View>

</asp:MultiView>

</div>


The code you posted isn't sufficient to reproduce the issue. Can you show me more?


<divstyle="border-bottom:dotted; border: 1px;">

<asp:RadioButtonID="RadioButton1"runat="server"Text="Address"GroupName="grpSelection"AutoPostBack="true"OnCheckedChanged="RadioButton1_CheckedChanged"Font-Bold="True"ForeColor="Blue"Width="80px"checked="true"/>

<asp:RadioButtonID="RadioButton2"runat="server"Text="Cities"GroupName="grpSelection"OnCheckedChanged="RadioButton2_CheckedChanged"AutoPostBack="True"Font-Bold="True"ForeColor="Blue"Width="67px"/>

<asp:RadioButtonID="RadioButton3"runat="server"Text="Zip Code"GroupName="grpSelection"OnCheckedChanged="RadioButton3_CheckedChanged"AutoPostBack="True"Font-Bold="True"ForeColor="Blue"Width="84px"/>

</div>

<scriptlanguage="c#"runat="server">

protectedvoid RadioButton1_CheckedChanged(object sender,EventArgs e)

{

MultiView1.SetActiveView(View1);

}

protectedvoid RadioButton2_CheckedChanged(object sender,EventArgs e)

{

MultiView1.SetActiveView(View2);

}

protectedvoid RadioButton3_CheckedChanged(object sender,EventArgs e)

{

MultiView1.SetActiveView(View3);

}

</script>

thanks.


Here is the page that I made with the codes your provided, it worked fine.

<%@. Page Language="C#" %><%@. Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %><!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 RadioButton1_CheckedChanged(object sender, EventArgs e) { MultiView1.SetActiveView(View1); } protected void RadioButton2_CheckedChanged(object sender, EventArgs e) { MultiView1.SetActiveView(View2); } protected void RadioButton3_CheckedChanged(object sender, EventArgs e) { MultiView1.SetActiveView(View3); } protected void btnAddress_Click(object sender, EventArgs e) { } protected void btnCities_Click(object sender, EventArgs e) { } protected void btnZip_Click(object sender, EventArgs e) { }</script><html xmlns="http://www.w3.org/1999/xhtml" ><head id="Head1" 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 runat="server" ID="up1"> <ContentTemplate> <div style="border-bottom:dotted; border: 1px;"><asp:MultiView id="MultiView1" runat="server" ActiveViewIndex="0"><asp:View ID="View1" runat="server"><asp:Label ID="lblMsg" runat="server" Width="273px" Font-Bold="True" ForeColor="Red"></asp:Label><br /><asp:TextBox ID="txtAddress" runat="server"></asp:TextBox><asp:Label ID="Label2" runat="server" Text="Ex. 101 Monroe St" Width="111px"></asp:Label><br /><asp:TextBox ID="txtZip" runat="server"></asp:TextBox><asp:Label ID="Label3" runat="server" Text="Ex. 20850" Width="106px"></asp:Label><br /><asp:TextBox ID="txtMiles" runat="server">2</asp:TextBox><asp:Label ID="Label4" runat="server" Text="Within Miles" Width="107px"></asp:Label><br /><asp:Button ID="btnAddress" runat="server" Text="Find" OnClick="btnAddress_Click" /></asp:View><asp:View ID="View2" runat="server"><asp:DropDownList ID="lstCities" runat="server"></asp:DropDownList><br /><asp:Button ID="btnCities" runat="server" Text="Find" OnClick="btnCities_Click" /></asp:View><asp:View ID="View3" runat="server"> <asp:DropDownList ID="lstZipCode" runat="server"></asp:DropDownList>     <asp:Button ID="btnZip" runat="server" Text="Find" OnClick="btnZip_Click" /></asp:View></asp:MultiView></div><div style="border-bottom:dotted; border: 1px;"> <asp:RadioButton ID="RadioButton1" runat="server" Text="Address" GroupName="grpSelection" AutoPostBack="true" OnCheckedChanged="RadioButton1_CheckedChanged" Font-Bold="True" ForeColor="Blue" Width="80px" checked="true" />    <asp:RadioButton ID="RadioButton2" runat="server" Text="Cities" GroupName="grpSelection" OnCheckedChanged="RadioButton2_CheckedChanged" AutoPostBack="True" Font-Bold="True" ForeColor="Blue" Width="67px" />      <asp:RadioButton ID="RadioButton3" runat="server" Text="Zip Code" GroupName="grpSelection" OnCheckedChanged="RadioButton3_CheckedChanged" AutoPostBack="True" Font-Bold="True" ForeColor="Blue" Width="84px" /></div> </ContentTemplate> </asp:UpdatePanel> </form></body></html>

Another tip is you need to make sure ajax extension is successfully installed on your machine, andnecessary entries have been added into your web.config.


thanks. let me try it out !


Hi.

just tried it. I don't have the file for AjaxControlToolkit, where may I find the file ?

thanks.


Hi.

In order to use UpdatePanel, I have to install AjaxControltoolkit, right ?

thanks.


shukuo:

Hi.

just tried it. I don't have the file for AjaxControlToolkit, where may I find the file ?

thanks.

http://www.codeplex.com/AtlasControlToolkit/Release/ProjectReleases.aspx?ReleaseId=4923


shukuo:

Hi.

In order to use UpdatePanel, I have to install AjaxControltoolkit, right ?

thanks.

No, Ajax Extension is enough.

MultiView containing an UpdatePanel: cant switch ActiveViewIndex?

I have a button control inside of an UpdatePanel. This UpdatePanel sits inside of a MultiView control (which is NOT inside another UpdatePanel, just a regular multiview). The function that is fired from the button click is supposed to change the ActiveViewIndex, but it does not. It fires off other actions inside the function, but does not change the multiview.


Is there something I need to do to get this to work? Here is roughly what I'm talking about. In this case it's set to ActiveViewIndex = 0. I need the button to change it to index 1. Thanks!!

<asp:MultiView runat="server" ID="someID">

<asp:View runat="server"

<asp:UpdatePanel runat="server">

<contenttemplate>

<asp:Button runat="server" onclick="MyFunction" Text="CLICK ME" />

</contenttemplate>

<asp:UpdatePanel>

</asp:View>

<asp:View runat="server">

SOME LITERAL HTML CONTENT

</asp:View>
</asp:MultiView


hi rpeters,

what are you using for your MyFunction?

should be something like this, right?

multiviewAppSec.SetActiveView((

View)this.multiviewAppSec.FindControl("ViewName")));

I was simply using...

myMultiView.ActiveViewIndex = 1;



pixelsyndicate:

hi rpeters,

what are you using for your MyFunction?

should be something like this, right?

multiviewAppSec.SetActiveView((View)this.multiviewAppSec.FindControl("ViewName")));

Tried using the approach as well. No difference... :(

Anyone??


I am pretty sure I tried that before, and didn't get it to work. the definition of that property says its Sets or Gets... so it should work. Try using the

SetActiveView(view) method to make that change. You will have to pass it a reference to the View you want however. Using the findcontrol() method example I used should help you to do that. Respond back on whether it worked or not. ;)


pixelsyndicate:

I am pretty sure I tried that before, and didn't get it to work. the definition of that property says its Sets or Gets... so it should work. Try using the

SetActiveView(view) method to make that change. You will have to pass it a reference to the View you want however. Using the findcontrol() method example I used should help you to do that. Respond back on whether it worked or not. ;)

Tried it...no luck. Same result as by setting the property.


Anyone else? There has to be a way!

you stated you were using 1 as the view index to display. isn't the view you want to show actually the first view? that would mean you need to display view index ZERO (0). indexes are zero-based, meaning its it this order...

0
1
2
3
4
5
6
...


pixelsyndicate:

you stated you were using 1 as the view index to display. isn't the view you want to show actually the first view? that would mean you need to display view index ZERO (0). indexes are zero-based, meaning its it this order...

0
1
2
3
4
5
6
...

I know that they are zero-based indices. I also am using the correct view index for my application. The problem is that it seems that because it is being called from a routine that is inside of an update panel, it is trying to make the change inside that panel, rather than changing the entire page to reflect the new panel.

anyone else?? thanks.

MultiView control, View control and nested UpdatePanels

I have an application that is using a MultiView control to simulate "tabs". Within that MultiView control, I have a number of View controls with nested UpdatePanels and they work just fine. However, whenever I try to encase the MultiView control inside an UpdatePanel, paging between the View controls works fine with no postbacks, but none of the UpdatePanels in any of the View controls works after that.

Has anyone ever run into this or provide any suggestions? Code samples available if necessary...

Thanks!

hello.

yes, seeing a small sample would help. btw, i must say that i still don't like the idea of nesting updatepanels.

MultiView in PopupControlExtender ?

I am trying to decide which ajaxtoolkit control to use for the following and if someone can point me to the correct direction, it would help alot.

I want to create poup window when click on a linkbutton. The popup window include asp.net server controls such as multiview or wizard which required popup to stay open even after the postback.

basically

1.user click on the linkbutton to open up popup window.

2. user fill up information on first view of the multiview and click next to go to next view

(catch the button next action on server side and do some action such as write to database, then change the multiview active index to second view)

3. user is provided with second view of the multiview while the popup still open

I can't use hovermenuextender because i want the popup to display when click action happened

I am trying out the popupcontrolextender but it close the popup window after user click next ( 2 ).

Here is the code, i have it so far.
123<asp:LinkButton ID="LinkButton1" runat="server" Text="Open Popup" />4<asp:Panel ID="Panel1" runat="server" CssClass="PopupStyle">5<asp:UpdatePanel runat="server" ID="UpdatePanel3">6 <ContentTemplate>78 <asp:MultiView ID="MultiView1" runat="server" ActiveViewIndex="0">9 <asp:View ID="View1" runat="server">10 View111 <asp:ImageButton ID="ImageButton1" runat="server" ImageUrl="btn_next.gif" />12 </asp:View>13 <asp:View ID="View2" runat="server">14 View215 <asp:ImageButton ID="ImageButton2" runat="server" ImageUrl="btn_complete.gif" />16 </asp:View>17 </asp:MultiView>18 </ContentTemplate>19 </asp:UpdatePanel>20 </asp:Panel>21<ajaxToolkit:PopupControlExtender ID="PopupControlExtender1" runat="server" TargetControlID="LinkButton1"22 PopupControlID="Panel1" Position="Bottom" >23</ajaxToolkit:PopupControlExtender>

With this code, it always close the popup after ImageButton1 in View1 is clicked. So i tried putting another updatepanel to wrapped the whole thing, once i do that the button click doesn't go back to server anymore.

What i am looking for exactly is an ajaxtoolkit control that create popup on clicked that can have any asp.net server control and stay open until user click close or certain button.

Any suggestion is appreciated.

thanks!


I guess i make it confused with my specific case. but it is quite simple what i want to do. so let me rephrase my question.

"Does anyone know which ajaxtoolkit control to use to create sticky popup with server controls which require postback?"


Really appreciate any suggestion even if there is no such control, please let me know.

Thanks very much.


Hi,

By default, popup extender doesn't support this behavior, but you can enable it by wrapping the wizard in a UpdatePanel.

Here is a sample that works:

<%@. Page Language="VB" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><script runat="server"> Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) MultiView1.SetActiveView(View2) End Sub</script><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> <asp:LinkButton ID="LinkButton1" runat="server" Text="Open Popup" /> <asp:Panel ID="Panel1" runat="server" CssClass="PopupStyle"> <asp:UpdatePanel runat="server" ID="UpdatePanel3"> <ContentTemplate> <asp:MultiView ID="MultiView1" runat="server" ActiveViewIndex="0"> <asp:View ID="View1" runat="server"> View1<asp:Button ID="Button1" runat="server" Text="Next" UseSubmitBehavior="false" OnClick="Button1_Click" /> </asp:View> <asp:View ID="View2" runat="server"> View2 <asp:Button ID="Button2" runat="server" Text="Complete" UseSubmitBehavior="false"/> </asp:View> </asp:MultiView> </ContentTemplate> </asp:UpdatePanel> </asp:Panel> <ajaxToolkit:PopupControlExtender ID="PopupControlExtender1" runat="server" TargetControlID="LinkButton1" PopupControlID="Panel1" Position="Bottom" > </ajaxToolkit:PopupControlExtender> </div> </form></body></html>
Hope this helps.

Thanks you Raymond for the reply. Just in case someone wondering how this goes. Here is what i ended up with. There is one that worth mentioning here. The property UseSubmitBehavior is a must so you must used button or similar control. The main problem that i have before was using imagebutton. I was using two updatedpanel nested and somehow imagebutton never make the server call. but the button did with UseSubmitBehavior set to false.

1 <asp:ScriptManager ID="ScriptManager1" runat="server">
2 </asp:ScriptManager>
3 <asp:UpdatePanel runat="server" ID="UpdatePanel1">
4 <ContentTemplate>
5 <asp:LinkButton ID="LinkButton1" runat="server" Text="Open Popup" />
6 <asp:Panel ID="Panel1" runat="server" CssClass="PopupStyle">
9 <asp:MultiView ID="MultiView1" runat="server" ActiveViewIndex="0">
10 <asp:View ID="View1" runat="server">
11 View1
12 <asp:Button ID="Button1" runat="server" Text="Next" UseSubmitBehavior="false" OnClick="Button1_Click"
13 CssClass="ButtonSubmit" />
14 </asp:View>
15 <asp:View ID="View2" runat="server">
16 View2
17 <asp:Button ID="Button2" runat="server" Text="Complete" UseSubmitBehavior="false"
18 CssClass="ButtonComplete" />
19 </asp:View>
20 </asp:MultiView>
23 </asp:Panel>
24 <ajaxToolkit:PopupControlExtender ID="PopupControlExtender1" runat="server" TargetControlID="LinkButton1"
25 PopupControlID="Panel1" Position="Bottom">
26 </ajaxToolkit:PopupControlExtender>
27 </ContentTemplate>
28 <Triggers>
29 <asp:AsyncPostBackTrigger ControlID="Button1" EventName="Click" />
30 <asp:PostBackTrigger ControlID="Button2" />
31 </Triggers>
32 </asp:UpdatePanel>

thanks for the helps. hope this help someone also.

MultiView, User Controls, PopupControlExtender

I have a webpage containing a MultiView. I put a user control in every view of the MultiView. From each user control, I use the ModalPopupExtender to open another user control, which contains fields for entering dates. I then use the calendar control and PopupControlExtender to select date.

It works fine when only one user control in the modal popup window has the calendar control and the PopupControlExtender. If more than one user controls opened with the modal popup extender have the calendar control and the PopupControlExtender, none of them works. In the latter case, I can still popup the calendar, but it doesn't allow me to select date, and it doesn't close. The calendar would dispear if I click outside the calendar area. But then I can't close the window containing the user control opened with the modal popup extender.

Anyone has similiar experience?

Please try your scenario with the recently available61020 release of the Toolkit (and ASP.NET AJAX Beta 1). If the problem persists, then please reply with acomplete, self-contained sample page that demonstrates the problem. Thank you!

Mutiple update panel - How to bind trigger event for control which is inside of other upda

Hi,

Thanks for visitng my problem.

I have 3 update panels. in first update panel U1 I have text box T1 and drop dwonbox D1.In second update panel U2 i have only drop down box D2. and in third update panel U3 i have a treeview T1.

I want that When I change selection of D1 in U1, it triiger events for D2 in U2 and T1 in U3. But when I try to bid U2 with D1 change event it does not show show D1 namein triiger control names. Rather it shows U1 panel name. Sam case is for T1 in U3. So my qiestion is : "HOW TO BIND TRIGGER WITH CONTROL WHICH IS INSIDE OF OTHER UPDATE PANEL?"

Looking for your Help.

Thanks,

John

Hi John,

I think the easiest solution would be to place one UpdatePanel around all three controls. If this doesn't work for you, perhaps you could post asmall code sample showing what you already tried.

Thanks,
Ted

My (Un)Modal Popup

I have added a modal popup to my user control. I show the modal popup by registering a startup script in the code-behind of an update panel trigger. The modal popup appears, but it isn't modal. I can click and edit the form fields behind the modal popup. Has anyone seen this happen? Any thoughts on how to fix it?Post code and I might be able to help you

Have you set the BackgroundCSSClass properly? I saw the same behavior and was able to fix it by setting the BackgroundCSS... here's an example of the CSS I used

.modalBackground

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

}


I used below css but still my main page controls can be accessed?

.modalBackground

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

}

This is happening in (Un)Modal fashion, any have solution for this.

My Custom Control Extender no longer works

I have a control extender that disabled a button when clicked to prevent multiple clicks. It worked well on my test.aspx page but when I moved it over to my big project, I get this error:

"Sys.ArgumentException: Value must not be null for Controls and Behaviors.Parameter name: element"

The page I moved it on contains a MasterPage with a home.aspx, and within that there is a .ascx and in there is where my button + control extender are found. Here is the code.

.cs:

using System;
using System.Collections.Generic;
using System.Text;
using System.Web;
using System.Web.UI.WebControls;
using System.Web.UI;

[assembly: System.Web.UI.WebResource("OneClickExtender.OneClick.js","text/javascript")]

namespace OneClickExtender
{
[TargetControlType(typeof(Button))]
[TargetControlType(typeof(ImageButton))]
public class OneClick : ExtenderControl
{
private string _submitScript = null;
protected override IEnumerable<ScriptDescriptor> GetScriptDescriptors(Control targetControl)
{
ScriptBehaviorDescriptor behavior = new ScriptBehaviorDescriptor("OneClickExtender.OneClickBehavior",targetControl.ID);
behavior.AddProperty("submitScript", _submitScript);

yield return behavior;

}

protected override IEnumerable<ScriptReference> GetScriptReferences()
{
ScriptReference sr = new ScriptReference();
sr.Name = "OneClickExtender.OneClick.js";
sr.Assembly = "OneClickExtender";

yield return sr;
}

protected override void OnLoad(EventArgs e)
{
base.OnLoad(e);
Control target = new Control();
target = FindControl(this.TargetControlID);
if (target != null)
_submitScript = Page.ClientScript.GetPostBackEventReference(target, string.Empty);
}
}
}

.js:


Type.registerNamespace('OneClickExtender');

OneClickExtender.OneClickBehavior = function(element) {
OneClickExtender.OneClickBehavior.initializeBase(this, [element]);
var _clickDelegate = null;
var _onSubmitScript = null;


}

OneClickExtender.OneClickBehavior.prototype = {
initialize : function() {
OneClickExtender.OneClickBehavior.callBaseMethod(this, 'initialize');
var e = this.get_element();
this._clickDelegate = Function.createDelegate(this,this._onClickDelegate);
$addHandler(e,"click",this._clickDelegate);
},

_onClickDelegate : function() {
this.get_element().disabled = true;
eval(this._onSubmitScript);
},

get_submitScript : function() {
return this._onSubmitScript;
},

set_submitScript : function(value) {
this._onSubmitScript = value;
},

dispose: function() {
$clearHandlers(this.get_element ());
OneClickExtender.OneClickBehavior.callBaseMethod(this, "dispose");
}
}

OneClickExtender.OneClickBehavior.registerClass("OneClickExtender.OneClickBehavior", Sys.UI.Behavior);

--

Any ideas?

hello.

instead of using targetcontrol.id i think that you should use targetcontrol.clientid.


This fixed it. However, because I am using asp:RequiredFieldValidator, my button gets disabled and never re-enables itself. I would have to make sure all fields were valid first. I will look into this right now.

My extender control wires its events, then seems to forget what it is!

I've created an extender using the Ajax Extender Control Template. It takes a TextBox as its TargetControl and adds a couple of drop downs to its child controls. Then it responds to the onblur event of the text box. It is supposed to set the values of the drop downs before it posts back. The problem is that when the text box fires its 'blur' event I can't use the 'this' keyword to refer to any of the classes properties or methods. Here is a brief snippett:

Company.Web.MASW.ProductAutoCompleteBehavior.prototype = { initialize : function() { Company.Web.MASW.ProductAutoCompleteBehavior.callBaseMethod(this,'initialize'); $addHandler(this.get_element(),'blur',this._elementChanged ); $addHandler(this._DiameterElement,'click',this._setElementValue ); $addHandler(this._TypeElement,'click',this._setElementValue ); },... _elementChanged : function(e) { alert(this.get_element()); }, _setElementValue : function(e) { alert( this._DiameterElement ); }}
 

The alert commands just verify that I've managed to make the connection to the right input element. It should pop up and say [object] but I get a script error saying object does not support this property or method. I just can't understand how it's calling the right event but can't see it's own properties. Could It be that it's inheriting from the AjaxToolkit.BehaviorBase class?

It seems as though I have a lot to learn about how to connect everything in Ajax. I've done a fair amout of JavaScript and I've done a fair amount of JScript in ASP. I have got a lot to learn about how Ajax connects ECMA, EMCA, E=MC2, or what ever it's called. I just can't fool with it much more for now so consider this 'resolved'. Thanks to all those who read this and said "what in the world is he up to?"

Saturday, March 24, 2012

my javascript method not working with update panel

Hi All,

The gridview (inside a user control) i am using in my screen (.aspx page) have a Checkbox column in the end. When i click the checkbox in the header all the checkboxes are selected. (A long javascript code has been written for that in the user control)

Now I have applied a scriptmanager and update Panel on this user control, and since then the javascript which selects all the checkboxes is not working properly.

I would like to know what i can do to resolve this javascript issue. And also would like to know why using the basic tools of ASP.NET AJAX control is stopping my own javascript from firing.

Please Note: On leaving a validation on page, the page postback and shows the validation. After this the javascript of Gridview works fine.

I have tried searching on google, but was not able to find any satisfactory explanation to my problem. It would be great if you people can help me.

Thanks,

Shikha

Please post your source code.


Hi,

Thank you for your post!

It is normal when you place inline javascript in an undatepanel/

For more information and solution, seeUpdatePanel and Rendered (Inline)Javascript

It seems that the UpdatePanel essentially replaces the InnerHTML of a DIV with the delta returned from the server. If you try this yourself you will notice that any javascript elements in the html are not fired.

All javascript registered on the server-side (if you are using .NET) with the ScriptManager is put into a separate section of the returned delta. The atlas runtime obviously then loads these scripts into the document manually.

What if the returned HTML has Javascript tags already rendered in it? Nothing.:(
Such was our predicament and we had no control over the HTML that would be returned to the UpdatePanel (ReportViewer Control). Could we manually load the javascript ourselves when the UpdatePanel returns the payload? As it turns, we could.

You can create script elements on the fly and they get evaluated as you do. Atlas has the ScriptLoader object that will do it for you if your JavaScript is an external reference. Tweaking this idea we got a solution that found all the new Script elements and added them to the document.

If you have further questions,let me know.

Best Regards,

My masterpage still flickers!

I'm using masterpages. Here's the layout of the masterpage:

Top - Menu

Middle - Content

Right - gridview

The Problem:

I created a search control that simply does a customer locate. I dropped the control on an aspx page and added a button under the control that is used to load the selected row to the griview on the masterpage. When I click the button the row is added fine, but the screen is not acting atkas-like...it reloads.

I defined my scriptmanager on the masterpage. And I've tried the following 3 scenerios to make this work the "Atlas" way...to no avail.

1) Placing the updatepanel within the control itself, and referencing the button's click event using a <Trigger>.

2) Wrapping the entire control and button with an update panel.

3) Wrapping the control with an updatepanel, and referencing the button's click event using a <Trigger>.

I'm either doing something wrong, or this cannot be done using Atlas. Can updating a gridview on a masterpage from within a content page be done using Atlas?

Eric

Something simple first. Did you set

EnablePartialRendering

="true"

for the script manager?


based on my experience (coz I implemented this atlas on my site) and based on the videos given by this site, i setup this atlas this way:

1. my script manager is not in the masterpage. i put it on the aspx page.
2. i put the trigger control (like button) outside the updatepanel, or you can put it on a different updatepanel if necessary.

so far this setup works with me. no flicker.Smile

Enablepartialrendering is true.

I'll try moving the scriptmanager to inside the acsx...thanks for the advice.


Ok...I moved the scriptmanager to the aspx page, and added the trigger. But doing it that way results in an asynch postback, but there is no rendering of the gridview on the masterpage.

Any ideas?


i am not sure what's really happening with your proj but my site has 2 gridviews that talks to one another but I did not encouter the issue you have now. Try to setup the atlas controls again starting from zero and this time put the script manager in the aspx page.
I rebuilt the project with the same result. I guess i'll just live with the anomoly for now. thanks.
just a question. why do u have to wrap the buttons with the updatepanel? does your button need to do something after the postback? if not, free up the button.
try isolation test. apply atlas on controls (where necessary) one after another until you see where the problem lies.

I have tried the button within the updatepanel, and oustside of the updatepanel (referencing the button with trigger). I think i understand where the problem is, i just don't think it will work. The control is wrapped in an updatepanel, The button exists on the same page that i dropped the ascx control on, as does the scriptmanager. By clicking the button I wish to send the selected row to a grid that exists on the masterpage. When i wrap that grid with an updatepanel i get "cannot use an updatepanel without a scriptmanager error. When i drop a scriptmanager on the masterpage i get "cannot have 2 sciptmanagers" error. When i remove the scripmanger on the aspx page the the ascx is on, nothing is displayed in the grid. argghhh.

BTW, i really don't want to have the scriptmanager existing in the masterpage.

If you have an example of how you can get this situation to work it would be priceless.


i recommend the same. isolation test lets you see where the problem lies.
i'm confused as why a moderator set this post as "answered"... i do not see any semblence of a "that fixed my problem and it works now" yet in this topic, so how is it "answered" ?

hello.

if you can build a small demo project that reproduces , then this i wouldn't mind taking a look at it to see if i can understand what's going on...

My only AJAXified page is flashing when it loads

AJAX Programmers,
I have finally deployed a cascading drop down control from the ajax control tool kit to my live site. Right now it is the only ajax control on my newly ajaxified site, but I can't help but notice that this is the only page that flashes when it loads. Seewww.legislature.mi.gov/mileg.aspx?page=SponsorSearch for an example of this. Does this seem normal to you who are experience ajax programmers? I'm getting ready to apply some other ajax contols, but I fear those persons overseeing this site may frown upon this flashing effect. Does it seem like I may be doing something wrong?
Thanks,
Jenny

If you could post some of the code for the page it might help in identifying if there is some change that needs to take place or if it is an issue with AJAX.NET

What seems to be happening is that the flash occurs because the background is loaded first and then the page content vice on your other pages the content will get loaded and then the background will get populated.


I've seen your drop down control and it seems fine.
The control disables when it's data is being refreshed and this is what makes
the "flashing" effect. The page itself, however, is not reloaded.

If you want to assure your customers you may display your page with Firefox using FireBug
extension. The firebug console clears itself whenever the page is being replaced or reloaded
and you can tel for sure that the page does not refresh.

my web service call works from one page, not from the other.

have a user control that uses Atlas to call a web service. I drop
this control on a page in the root directory and it works with no
problem. I then add the control to another control, which is on
another page and it will not work. It does not seem to know what the
webService is.

My web service is in the same project and the ascx control and is named
meterCommunication.asmx in a folder called webService.

The control is a button ond onClick it callas a javascript function
that has the following line for calling the web service:
meterCommunication.sendMessage(meterID, commType, _onRequestComplete);

The error that I get is a javascript error that says:
meterCommunication is undefined

I can't figure out what is different between the two pages. Since this
is on a user control they should be identical.

How does the javascript know what meterCommunication is?
I don't know enough about this to troubleshoot the problem.

You need to make sure that you import the web service proxy, either in your page or in the user control. This is done using:
<scriptsrc="/yourapp/subdir/YourService.asmx/js"type="text/javascript"></script>
Maybe you have that only on the page that works?

My Web Page Is Too Big After Use Asp.Net Ajax & Control Toolkit

I installed and using the Asp.Net Ajax & Control Toolkit in my web site.I am enjoy the cool features , except for one problem : the web page became too big to open,because the script file too large(one file is 255KB).

Yes, I know if a user opened my web page once ,it will be faster ,because the script file will not download again . But I think major new visitor will not wait for 1 or 2 min to open my web .

Is any body has the same problem? And is a solution ?

Thanks a lot !

I install the Asp.net Ajax and Copy Control Toolkit dll file to my web site bin folder, and add reference it in web.

the 255KB file is :

http://www.iam2ya.com/ScriptResource.axd?d=vrvSMawp_0WGqqmTGX1asI3T2R_vAVNchQRILcRhDeu99DMl7dd3CdOiSAo_o9GSoON-VrGYckQdXYdSTjo6zEIuvurZyzx_M44XRjh_GYU1&t=633056550088536400

the Ajaxextention version is "v1.0.61025"

the Control Toolkit version is "1.0.10123.0 "

Hi,

in the web.config file, do you have debug="true"? If so, change it to false. This results in using the production client javascripts instead of the debug ones that are quite larger.

Grz, Kris.