Showing posts with label masterpage. Show all posts
Showing posts with label masterpage. Show all posts

Wednesday, March 28, 2012

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

Saturday, March 24, 2012

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...

MyNamespace.MyWebService has no properties error helpp!

Hi all, i have been having trouble getting this to work: Im using masterpages, i set the web reference on the scriptmanager in the masterpage, and the scripreference on the content page, also have a modalpoup IN the content page, a link button in a gridview template and on the clik event (kind of) i call the jscript function to show the modal and execute the webservice(shown below)

HAve a Webservice, that doas a sql query to get certain values from a database:

1using System;2using System.Web;3using System.Collections;4using System.Web.Services;5using System.Web.Services.Protocols;6using System.Web.Script.Services;7using System;8using AjaxControlToolkit;9using System.Data;10using System.Data.SqlClient;11using System.Collections;12using System.Collections.Generic;13using System.Collections.Specialized;1415/// <summary>16/// Summary description for CargarDatos17/// </summary>18[WebService(Namespace ="http://tempuri.org/")]19[WebServiceBinding(ConformsTo = WsiProfiles.BasicProfile1_1)]20[ScriptService]21public class CargarDatos : System.Web.Services.WebService {2223//public CargarDatos () {2425 // //Uncomment the following line if using designed components26 // //InitializeComponent();27 //}2829 [WebMethod()]30 [ScriptMethod()]31 public string GetDynamicContent(string ID_Cliente)32 {33 System.Data.SqlClient.SqlConnection Conn1 = new System.Data.SqlClient.SqlConnection("Data Source=DESKTOP;Initial Catalog=Encuestas;User ID=sa;Password=lf654");34 System.Data.SqlClient.SqlDataAdapter da1 = new System.Data.SqlClient.SqlDataAdapter("SELECT Nombre FROM Clientes WHERE ID_Cliente=@dotnet.itags.org.ID_Cliente", Conn1);35//System.Data.SqlClient.SqlCommand Cmnd = new System.Data.SqlClient.SqlCommand();36 //Cmnd.CommandText = "SELECT Nombre FROM Clientes WHERE ID_Cliente=@dotnet.itags.org.ID_Cliente";37 //Cmnd.Connection = Conn1;38 System.Data.DataSet ds = new System.Data.DataSet();39 try40 {41 da1.SelectCommand.Parameters.AddWithValue("@dotnet.itags.org.ID_Cliente",int.Parse(ID_Cliente));42 Conn1.Open();43 da1.SelectCommand.ExecuteNonQuery();44 da1.Fill(ds);45 Conn1.Close();46return ds.GetXml();47 }48catch (Exception ex)49 {50 Console.WriteLine(ex.Message);51return null;52 }53 }5455}

A Java script function that calls that web service (or at least try:P)

function ShowMyModalPopup(customerid){ var modal = $find('ModalPopupExtender1');

modal.show();

"http://tempuri.org/".CargarDatos.GetDynamicContent(customerid,DisplayResult);

 }

used to show a modalpopup and to pass on values to the web service, and if it works to call another jscript function to populate texboxes in the modalpopup panel.

Have 2 problems: im using firebug to debug client side, and its says to me: "http://tempuri.org/".CargarDatos has no properties...

i get this on the jsdebug:

var CargarDatos=function() {

2CargarDatos.initializeBase(this);

3this._timeout = 0;

4this._userContext = null;

5this._succeeded = null;

6this._failed = null;

7}

8CargarDatos.prototype={

9GetDynamicContent:function(ID_Cliente,succeededCallback, failedCallback, userContext) {

10returnthis._invoke(CargarDatos.get_path(),'GetDynamicContent',false,{ID_Cliente:ID_Cliente},succeededCallback,failedCallback,userContext);}}

11CargarDatos.registerClass('CargarDatos',Sys.Net.WebServiceProxy);

12CargarDatos._staticInstance = new CargarDatos();

13CargarDatos.set_path = function(value) {

14vare = Function._validateParams(arguments, [{name: 'path', type:String}]); if (e) throw e; CargarDatos._staticInstance._path = value; }

15CargarDatos.get_path = function() { return CargarDatos._staticInstance._path; }

16CargarDatos.set_timeout= function(value) { var e = Function._validateParams(arguments, [{name:'timeout', type: Number}]); if (e) throw e; if (value < 0) { throwError.argumentOutOfRange('value', value, Sys.Res.invalidTimeout); }

17CargarDatos._staticInstance._timeout = value; }

18CargarDatos.get_timeout = function() {

19return CargarDatos._staticInstance._timeout; }

20CargarDatos.set_defaultUserContext = function(value) {

21CargarDatos._staticInstance._userContext = value; }

22CargarDatos.get_defaultUserContext = function() {

23return CargarDatos._staticInstance._userContext; }

24CargarDatos.set_defaultSucceededCallback = function(value) {

25vare = Function._validateParams(arguments, [{name:'defaultSucceededCallback', type: Function}]); if (e) throw e;CargarDatos._staticInstance._succeeded = value; }

26CargarDatos.get_defaultSucceededCallback = function() {

27return CargarDatos._staticInstance._succeeded; }

28CargarDatos.set_defaultFailedCallback = function(value) {

29vare = Function._validateParams(arguments, [{name:'defaultFailedCallback', type: Function}]); if (e) throw e;CargarDatos._staticInstance._failed = value; }

30CargarDatos.get_defaultFailedCallback = function() {

31return CargarDatos._staticInstance._failed; }

32CargarDatos.set_path("/sovi1/CargarDatos.asmx");

33CargarDatos.GetDynamicContent=function(ID_Cliente,onSuccess,onFailed,userContext){CargarDatos._staticInstance.GetDynamicContent(ID_Cliente,onSuccess,onFailed,userContext);}

For the type of info there, i assume that it finds the web service, and i can see the method name there, so that should mean that im accesing the WS, but i still dont get why it fails, i never used jscript before neither web services, so its all new to me... so if anyone could point me in the right direction ill be more than gratefull.

Also, im having a Nullreference when i try to invoke the .show method from modalpopup, could this mean that im not finding the modalpopup control?

Plz i have been stuck at this point for over 4 days now.

Tnks in advance.


hi, you just need to drop the http://tempuri.org/" bit from the callback method name, so the method call would be CargarDatos.GetDynamicContent(customerid,DisplayResult);

Cheers Si


Tnks a millon man, it worked!! BUT for a reason... i previously had it that way, and i get the "web service not found error", this was while i was having both, the service reference and the script reference in a scriptmanagerproxy in a content page, i moved those references to a scriptmanager in the master page and then i was hable to find the web service (Mynamespace.mywebservice) but i was getting the above error. Now. i have all the references in the master page, and without the "MyNamespace" i got(U did actuallyStick out tongue) the web service to work.

So the web service issue its fixed, but im still having the modalpopup error, saying that has null on it, i also tryed using:

var modal=document.getElementById('<%=ModalPopupExtender1.ClientID%>');

and still no luck, the modal its on a content page inside a template field in a gridview, if someone can give me a clue on this than it′ll be a completely solved issue.

Tnks again for the rsponse dj Big Smile


No worries dude,

In respsone to your modalpopup problem

var modal=document.getElementById('<%=ModalPopupExtender1.ClientID%>');

This line will not work with the .show() method as it is trying to reference a DOM object not the modalpopup "Behavior" which controls a DOM element. It is the behavior that contains the .show() method. You were correct with this line
var modal = $find('ModalPopupExtender1');

But i'm guessing 'ModalPopupExtender1'is the wrong ID. I guessing if you use $find('<%=ModalPopupExtender1.ClientID%>') this might work, otherwise a quick and dirty way is to view source and look for a line like this(this is from the toolkit samples)

$create(AjaxControlToolkit.ModalPopupBehavior, {"BackgroundCssClass":"modalBackground","DropShadow":true,"PopupControlID":"ctl00_SampleContent_programmaticPopup","PopupDragHandleControlID":"ctl00_SampleContent_programmaticPopupDragHandle","dynamicServicePath":"/AJAX/AjaxControlToolkit/Samples/ModalPopup/ModalPopup.aspx","id":"programmaticModalPopupBehavior","repositionMode":2}, null, null, $get("ctl00_SampleContent_hiddenTargetControlForModalPopup"));

look for this property "id":"programmaticModalPopupBehavior" to find the ID you need to use in the $find() method, in this case it would be $find("programmaticModalPopupBehavior")

Cheers Si


Hi again... as before, u where right on that one too, i was hable to find the modalpopup using the behaviorIDBig Smile, and i need ur wisdom another time to finally get this thing to work, and also ill share a little revelation i had(im sounding like agent Smith...)anyway...im having a lot of trouble finding the textboxes to fill with my jscript function i tryed all this:

document.getElementById('ctl00_ContentPlaceHolder1_TxBxNombreCliente').value=xmlvalue;
document.getElementById('TxBxNombreCliente').value=xmlvalue;
document.getElementById('<%=ContentPlaceHolder1.TxBxNombreCliente.ClientID%>').value=xmlvalue;
document.getElementById('ContentPlaceHolder1.TxBxNombreCliente').value=xmlvalue;
$find('TxBxNombreCliente').value=xmlvalue;
$find('<%=TxBxNombreCliente.ClientID%>').value=xmlvalue;

and absolutely none worked (im trying to set a texbox value).

My revelation its the next... have a masterpage and a few contentpages the thing its that i needit to pass on some values from a content page to another, so i used the Server.Transfer("page2.aspx") on the source page, and virtual path and context.handler on the destination page, being in that one where i was invoking my javascript... and i realized that when y pass on from one webform to the other... the url didnt change so im seeing the content of page2... with the url of page1... so i moved the modalpopup panel to page 1... and was hable to get the thing to work using the

document.getElementById('ctl00_ContentPlaceHolder1_TxBxNombreCliente').value=xmlvalue;

VERY weird... but.. i dont want to use this solution... i want to be hable to find the textbox correcty (also tryed all the above options and none but this one worked)... im clueless by now... u have any idea to share?

Tnks again for the modalpopup thingBig Smile

Farewell

Leandro


HI all again... ill response myself on this matter, cause i was hable to find its solution.

After a lot(A LOT) of testing i manage to locate the control i was searching wothout using the $100_etc_etc_etcMyControl, how? i decided to stop using an external jscript file, and i embbeded the jscript whitin the content tags of the content page, then.. and ONLY then, i could find the textbox using the document.getElementById('<%=TxBxNombreCliente.ClientID%>').value=xmlvalue;

BUT i still cant do it from an external jscript file.... hope that this helps someone else with my same trouble.

Best regards and thns for all...See you all people soonStick out tongue


Farewell