Showing posts with label panel. Show all posts
Showing posts with label panel. Show all posts

Wednesday, March 28, 2012

PostBack is happening even after using Update Panel and Script Manager

Hi,

I have a ASP.NET web application. I have a gridview and using a RowDataBound andRaisePostBackEventevent for getting the GridView details in the controls below like textboxes, dropdown etc. Now i am using Ajax Extensions controls like Update Panel and Script manager to avoid a postback happening when the GridView row is clicked. Even after implementing them postback is happening. Please see the code bits and let me know if i am missing somewhere.

UI

<asp

:ScriptManagerID="ScriptManager1"runat="server"EnablePartialRendering="true"></asp:ScriptManager>

<

asp:UpdatePanelid="UpdatePanel1"runat="server"UpdateMode="Conditional">

<contenttemplate>

<asp:GridViewID="GridView1"runat="server"OnRowDataBound="GridView1_RowDataBound"CssClass="sampletable"AlternatingRowStyle-CssClass="d1"ShowHeader="true"ShowFooter="false"AllowPaging="true"AllowSorting="true"AutoGenerateColumns="false"DataKeyNames="ProjectID"Width="100%"PageSize="5"><Columns>

<asp:BoundFieldVisible="false"HeaderText="Project ID"DataField="ProjectID"SortExpression="ProjectID"/><asp:BoundFieldHeaderText="Project Name"DataField="ProjectName"SortExpression="ProjectName"/><asp:BoundFieldHeaderText="Site Name"DataField="SiteName"SortExpression="SiteName"/></Columns></asp:GridView><asp:LabelID="Label1"runat="server"Text="Label"></asp:Label><asp:TextBoxID="TextBox1"runat="server"></asp:TextBox><asp:ButtonID="Button1"runat="server"Text="Button"/>

</

contenttemplate>

<

Triggers>

<

asp:AsyncPostBackTriggerControlID="GridView1"EventName="RowDataBound"/>

</

Triggers>

</

asp:UpdatePanel>

And theCode behind for RowDatabound event is

protected

void GridView1_RowDataBound(object sender,GridViewRowEventArgs e)

{

try

{

if (!((e.Row.RowType ==DataControlRowType.Pager) || (e.Row.RowType ==DataControlRowType.Header) || (e.Row.RowType ==DataControlRowType.Footer)))

{

System.Web.UI.

ClientScriptManager cs = Page.ClientScript;//Assign Row Index. This row index used in finding the ID of the clicked rowint intRowIndex = e.Row.RowIndex;

e.Row.Attributes.Add(

"onClick", cs.GetPostBackEventReference(this, intRowIndex.ToString().Trim()));

e.Row.Attributes.Add(

"onKeyDown","if( event.keyCode == 13 ) " + cs.GetPostBackEventReference(this,"KEYDOWN" +"$" + e.Row.DataItemIndex.ToString().Trim()));

}

}

catch (System.Exception ex)

{

//OnError(ex);

}

}

The code looks good, did you try a easy test to see if the postback is hidden?

http://alpascual.com/blog/al/archive/2006/12/21/Code-Snip-_2200_AJAX-Timer_2200_.aspx

Try the sample below and let me know if you see the postback


Thanks for the Quick Response.

But i could not get exactly what you want to convey.

regards,

Parimal


Ok, wrap a asp:button around an updatepanel and let me know if you see the postback

Hi,

The button is working fine without any post back. The Post back is happening when Grid Row is clicked as it call the RaisePostBack event to get the Row details. That event is coded as we have not used any command template in Grid.

regards,

Parimal


OnRowDatabound would not make sense for an async trigger. The user clicking the row and getting a postback via the javascript you added to the onclick is not the same. If you take out the trigger and just add ChildrenAsTriggers="true" to the UpdatePanel it would probably work as you expect.

One other thing - in this code:

"onClick", cs.GetPostBackEventReference(this, intRowIndex.ToString().Trim()));

e.Row.Attributes.Add(

"onKeyDown","if( event.keyCode == 13 ) " + cs.GetPostBackEventReference(this,"KEYDOWN" +"$" + e.Row.DataItemIndex.ToString().Trim()));

Change "this" to GridView1. You want to create a postback for your gridview, not the whole page. Since you're creating a custom postback you'll also need to register for event validation, or disable event validation in your page.


Thanks for the response. But still post back is happening. I will explain in details

1. I have a Gridview RowDataBound event which fires when Data is bounded to Grid.

2. I have aRaisePostBackEvent which fires when the row in the Grid is selected and this causes the Post Back event.

3. Aslo my UserControl is implementingIPostBackEventHandler interface.

Thanks in Advance,

Parimal

Postback Page controls go reverse video

I'm using master pages, and have various content pages using the same paster page, with an update panel in my paster page, that wraps my content pages. All works very well.

However, on some content pages if I double click my rows in my Gridview to cause an edit of that record, all the controls on the page are reverse video for a brief second, this is only true on some content pages, not all. I've recreated one of the content pages in question from scratch, same issue.

Has anyone else ran into this reverse video issue before?

No,I have never ran into this issue before.So I'm afraid I donn't have any idea on it if you don't provide with a repro of it.

Regards

postback problem

Hi,

I have a control in my update panel which gets data from the database. The trigger for the update panel is a button control. its working fine ( i mean partial page update is happening) when i run my application.

But when this page is opened from an other user's browser, the whole page ( with all the other controls outside the update panel ) is being posted back on button click.

Any help is appreciated.

Hi developer_dotnet,

The same page has different behaviour in another users browser. Can you past your code here so we can analyze it. Thanks

Regards,


Hi developer,

developer_dotnet:

its working fine ( i mean partial page update is happening) when i run my application.

.

You mean in your development environment or you have published your website on this spot ?

developer_dotnet:

But when this page is opened from an other user's browser, the whole page ( with all the other controls outside the update panel ) is being posted back on button click.

First, suggest that we should use a debug tool such as Web Development Helper to make sure whether it make a asynchronous post or not.

If not , we should pay our attention to check if Asp.Net Ajax Extension V1.0 has been installed in the machine which host your website. http://ajax.asp.net/docs/InstallingASPNETAJAX.aspx .If Aajx ControlToolkit Controls used in your application, please add "AjaxControlToolkit.dll" to your bin folder.

If yes , please check the web.config settings .http://ajax.asp.net/docs/ConfiguringASPNETAJAX.aspx

If the problem cannot been resolved by doing these, please show your simple source code here.


I had a similar issue of partial postback. I have made it into a seperate <table> and it worked.


Hi all,

If an Ajax-Enabled page doesn't work properly in the browser, we may do some checking on the broswer security and privacy setting.

The following table lists required browser security and privacy settings for both user browsing and site development. In all cases, the recommended settings are the default settings for that browser.

Internet Explorer 6

Make sure that theInternet Zone in the Security Zones settings is set toMedium.

Internet Explorer 7

Make sure that theInternet Zone in the Security Zones settings is set toMedium-High.

FireFox 1.5 or later versions

In theTools menu underOptions, make sure thatEnable JavaScript is selected.

Opera 9.0 or later versions

In theTools menu underQuick preferences, make sure thatEnable JavaScript is selected.

Safari 2.0 or later versions

ClickSafari,Preferences,Security, and then Web Content and make sure thatEnable JavaScript is selected.

Hope it helps.

Postback problem using a usercontrol inside an update panel that is inside a masterpage

Hi all,

I have been messing around with this all day and its starting to get on my nerves i'm probably missing something really simple but I was hoping someone could shed some light on it or perhaps point me in the right direction..

As I said in thesubject of the post, I have a user control inside an update panel, that resides in the master page, now my problem is when the user control goes to perform a post back I get that nasty "Invalid callback or postback argument error" Can someone help me to rectify this issue? Basically all the control needs to do is hide one panel inside it and show another on a link buttons click even.. There is other code in there too..

The simplified code for the master page is as follows..

<%

@dotnet.itags.org.MasterLanguage="VB"CodeFile="redcellar.master.vb"Inherits="redcellar" %>

<%

@dotnet.itags.org.RegisterAssembly="AjaxControlToolkit"Namespace="AjaxControlToolkit"TagPrefix="ajaxToolkit" %>

<%

@dotnet.itags.org.RegisterSrc="login.ascx"TagName="login"TagPrefix="uc2" %>

<%

@dotnet.itags.org.RegisterSrc="controls/memberdeals.ascx"TagName="memberdeals"TagPrefix="uc1" %>

<!

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

<

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

<

headrunat="server"><metahttp-equiv="content-type"content="text/html;charset=utf-8"/><linkrel="stylesheet"type="text/css"media="screen, projection"href="stylesheets/screen.css"/><!--[if lte IE 6]>

<link rel="stylesheet" type="text/css" media="screen, projection" href="http://links.10026.com/?link=stylesheets/screen-ie.css" /><![endif]-->

<linkrel="stylesheet"type="text/css"media="screen, projection"href="stylesheets/order.css"/><!--[if lte IE 6]>

<link rel="stylesheet" type="text/css" media="screen, projection" href="http://links.10026.com/?link=stylesheets/order-ie.css" /><![endif]-->

<scripttype="text/javascript"src="scripts/borders.js"></script><scripttype="text/javascript"src="scripts/misc.js"></script><title></title>

</

head>

<

body><formid="form1"runat="server"><asp:ScriptManagerEnablePartialRendering="true"ID="masterScriptManager"runat="server"/><asp:UpdatePanelID="masterUpdatePanel"runat="server"><ContentTemplate><!-- container --><divid="container">

<p>page content is here</p>

</div><uc2:loginID="Login1"runat="server"/></ContentTemplate></asp:UpdatePanel>

And the code for the control is:

<%

@dotnet.itags.org.ControlLanguage="VB"Debug="true"AutoEventWireup="false"CodeFile="login.ascx.vb"Inherits="login"Strict="true" %><asp:PanelID="pnlLoginContainer"CssClass="modalPopup"runat="server"><divid="normal"><asp:PanelID="pnlLogin"runat="server"style="overflow: auto;"><divstyle="width: 160px; float: right;"><asp:linkbuttonID="lbClose"cssclass="modalClose"Text=""runat="server"/><asp:ImageID="Image1"runat="server"ImageUrl="~/images/member-red-large.gif"/></div><div><br/><h3id="normalpage_heading">

Member sign in.

</h3><br/><asp:LabelID="Label1"runat="server">Welcome back!</asp:Label><br/><br/><tablecellspacing="0"><trclass="datarow"><tdclass="itemheader"><asp:LabelID="Label2"runat="server"Text="email"/></td><tdclass="itemcontent"colspan="2"><asp:TextBoxID="txtEmail"runat="server"MaxLength="255"/></td></tr><trclass="datarow"><tdclass="itemheader"><asp:LabelID="Label3"runat="server"Text="password"/></td><tdclass="itemcontent"colspan="2"><asp:TextBoxID="txtPassword"runat="server"MaxLength="50"TextMode="Password"/><asp:RequiredFieldValidatorID="RequiredFieldValidator1"runat="server"ControlToValidate="txtpassword"Display="Dynamic"ErrorMessage="*"/></td></tr><trclass="datarow"><tdclass="itemheader"> </td><tdclass="itemcontentsmall"><asp:CheckBoxID="chkRememberMe"runat="server"Text="remember me"/></td><tdclass="itemcontentsmall"style="text-align: right;"><asp:LinkButtonID="lbForgotPassword"runat="server"CausesValidation="False"Text="forget your password?"/></td></tr></table><br/><divclass="link"id="signin-link"><asp:LinkButtonID="cmdLogin"runat="server"Text="sign in"/></div><br/><asp:LabelID="lblLoginMsg"runat="server"ForeColor="Red"></asp:Label><br/></div><div><asp:LabelID="Label4"runat="server">Are you a new user? You must register</asp:Label><asp:LinkButtonID="lbRegister"runat="server"CausesValidation="False"Text="here!"ToolTip="Click here to register.">here!</asp:LinkButton></div></asp:Panel><asp:PanelID="pnlForgotPass"runat="server"Width="100%"style="overflow: auto;"Visible="False"><divstyle="width: 160px; float: right;"><asp:linkbuttonID="Linkbutton1"cssclass="modalClose"Text=""runat="server"/><asp:ImageID="Image2"runat="server"ImageUrl="~/images/member-red-large.gif"/></div><div><p>

Forgot you password?

</p><asp:LabelID="Label5"runat="server">email</asp:Label><asp:TextBoxID="txtForgotPassEmail"runat="server"></asp:TextBox><asp:RequiredFieldValidatorID="RequiredFieldValidator2"runat="server"ControlToValidate="txtForgotPassEmail"Display="Dynamic"ErrorMessage="*"></asp:RequiredFieldValidator><asp:RegularExpressionValidatorID="RegularExpressionValidator1"runat="server"ErrorMessage="You must enter a valid email!"ControlToValidate="txtForgotPassEmail"SetFocusOnError="True"ValidationExpression="^([0-9a-zA-Z]([-.\w]*[0-9a-zA-Z])*@dotnet.itags.org.([0-9a-zA-Z][-\w]*[0-9a-zA-Z]\.)+[a-zA-Z]{2,9})$"Display="Dynamic"></asp:RegularExpressionValidator><br/><br/><asp:LabelID="lblResponseMessage"runat="server"></asp:Label><br/><pstyle="text-align: right;"><asp:ButtonID="cmdForgotPass"runat="server"Text="submit"/> </p></div></asp:Panel></div></asp:Panel>

The relevant code behind for this is:

ProtectedSub lbForgotPassword_Click(ByVal senderAsObject,ByVal eAs System.EventArgs)Handles lbForgotPassword.Click

pnlLogin.Visible =

False

pnlForgotPass.Visible =

TrueEndSub

Some help with this would be greatly appreciated.. :)

I'm still stuck with this one :S Any ideas?


After eliminating one thing at a time in my masterpage I found that this was the culprit, commenting it out did the trick..

<form method="get" action="">
<p><label for="search">Find a wine:</label>
<input type="text" id="search" onfocus="if(value=='eg: Henschke') value=''" value="eg: Henschke" />
<input type="image" src="http://pics.10026.com/?src=images/go.gif" value="Go" id="go" /></p>
</form>


does anyone have any idea why??

Postback Slowdown

I have a page that contains a table inside an update panel. The table is 10 columns wide and when the page is initially loaded it only contains the header row and a + under the table to add a row. The problem I have is after adding 4 rows the 5th slows down a lot. And from then on addings more rows gets slower and slower. Whenever the + is clicked it causes the update panel to update and dynamically recreate the table with another row. So it starts by just creating the header. The first time you click the + it creates the header and the 1st row. The next time it creates the Header and 1st and 2nd rows.. and so on.

I cannot figure out a way to speed this up, and as the user approaches 10 rows it begins to slow down to 3 to 4 seconds after htiting the button that anything happens. I think the problem is the viewstate is getting huge and causing it to be much slower. I cannot even get update progress images to work. They don't pop up right away, and when they do pop up they go away immediatly.

Any suggestions on ways to improve the speed? Or I am stuck dealing with a slow page.

Can you post any code?


You're right. The viewstate gets sent back for every AJAX call which means that adding a row

may as well be posting the whole page to the server from the servers point of view.

Use this plugin to see what's being sent over the wire:http://www.nikhilk.net/Project.WebDevHelper.aspx

Check outhttp://smarx.com/posts/delayed-load-with-an-updatepanel.aspx

This shows the oposite of what you're doing.

What you need to do is just update the new row instead of the whole grid.

HTH,

Jonathan.


Is there a way to add a row without recreating the whole table? If I update the panel without recreating the table the table goes away right now.

Thanks for the plugin, I will have to check that out.


Try to set <compilation debug = "false" />

may it will improve some ammount of performance..


If you have each row in a div for example:

<div id="table">
 <div id="row1">hello row 1</div>
<div id="row2">Hello row 2</div>
</div>
<asp:Button ID="clickme" runat="server" OnClientClick="javascript:updateTable(); return false;" Text="Add Row" />

Then you could do the following in JavaScript:

<script type="text/javascript">
function updateTable()
{
var table = document.getElementById("table");
table.innerHTML = table.innerHTML + "<div id='row3'>hello row 3</div>";
}
</script>

HTH,

Jonathan.



I have the same problem. Luckily, after optimizing the 'retrieval time'/row, the speed was acceptable for the number of rows I wanted to display.

If you want speed, you can try using the JavaScript method above, and don't update via Updatepanel. So your buttons change the data behind the scenes (without postback), while calling the JavaScript to show the updates.

Postback to Open Window

i have a button in an update panel that checks through some business logic and if errors/warnings are generated i need to report them to the user.

i have no room on the screen to use for this and would like to show a dialog/window with anything to report.

anyone any ideas on how i could achieve this?

cheers

you can try to build a message control that has absolute position (CSS) , and it located in the center of the page (on top of every elements of page (using z-index)) with ok and close button.

the message control will be placed in every page and have it hidden before any message send, maybe you want to put it in master or basepage if there are a lot of pages going to use the control.


Use javascript:window.alert('Your message here!');


If you're using the AJAX Toolkit, check out theModalPopup Extender.

If you're not, jQuery'sBlockUI plugin is a nice way to accomplish that as well.


thanks for all the feedback.

i eventually used the modalpopup to handle this and works perfectly.

thanks again all...

Postback with button IN Update panel

Hello,

Q, I have 2 update panel's, one panel has 3 button's in it, say button1, button2, button3. Now i need to find a way to have a whole page postback with button1 (in update panel1) and a partial postback on button2 (also in panel1) . Is this posible.

Thanks in advange

Greetings Henk

hello.

well, you can try to add a dummy button outside the panel and then when the user clicks the button you'd call the click method over the other button...


In Atlas 1.0 we'll have a way to tell the UpdatePanel that certain controls should cause a regular postback even though they're inside the UpdatePanel. For now you'll have to use a workaround (such as the one described previously).

Thanks,

Eilon


Hmm, I tryed that, but that did not sucseed. I get the error btnDumie does not exist or sumthing like that. the problem is (I think that the submit button is only visible after an panelupdate, so that panel can't acces other elements on the page??)

I hope there is another sollution.


If it's possible in your scenario you could try to divide up your page such that the regular-postback button isn't inside an UpdatePanel. Once Atlas 1.0 is released you'll be able to do this very easily, but it's not quite ready yet.

Thanks,

Eilon


I am having the same issue. When is Atlas 1.0 due for release?

Thanks,

Murali


Here's the Atlas roadmap:http://weblogs.asp.net/scottgu/archive/2006/09/11/_2200_Atlas_2200_-1.0-Naming-and-Roadmap.aspx

Thanks,

Eilon


hello.

well, that post gives some clues, but no spcific date. btw, when are you guys start sharing the current versions you're developing with us? after all, i've been using atlas for months now and i've seen several posts where you guys say something like: "well, in v1.0 that problem is solved" or "you'll be able to do that easilly"...this just isn't enough!

according to the team's comments, it's as if you're changing several internal key parts of atlas. it's not that i'm against it, but you should also keep in mind that there are several people building applications with atlas and it' won't be a lot of fun to find out that v1.0 is out and that everything is completly different (when compared with the ctps!).

thanks.


I think the reason that we're not giving out a date is that there isn't a specific date chosen yet. What we will have is public previews of the new 1.0 Atlas (soon, but I'm not surehow soon). We'll also have a comprehensive document that describes the changes between the older Atlas CTPs and the new Atlas 1.0 CTPs so you can scan through it and identify any changes that you will have to make.

Thanks,

Eilon

Postbacks and animationextender / modalpopupextender

I have a usercontrol which handles its own postbacks. I would like to place this usercontrol in a panel, which gets displayed either using the animationextender or the modalpopupextender. The problem is that when a user clicks on any control which fires the postback in the usercontrol, the usercontrol disappears from the page.

Would anyone happen to know how to prevent the target panel of a modalpopupextender or animationextender from disappearing on a postback? Thanks!

Have you gotten anywhere with this problem? I just came across this issue and need to also understand how to properly do this. Thanks.

Posting Back From Client

Hello,

I have a question about posting back from the client. How do I cause an update panel to update from the client? What I want to do is pop up another window, do some things on it, and have it update a gridview on the page that opened the window. I'm assuming I can do this with javascript. Can anyone point me in the right direction?

Thanks,

Nick

Anyone have any suggestions?

Prefetching Images

I am using the update panel, and the timer control to automatically change a person's profile text, and their photo (small 65x65 pixels). Everything works well so far, except the transition is not always smooth for the photo.

Before the images/photos become cached in the browser, the default broken (link-to-image) image shows up, before the relevant photo loads. After that image loads the first time, the transition is smooth.

Is there a way to prefetch these images (approximately 8) when the page loads?

Thanks,

Karls

The easiest way I know of is to create a .js function to preload the images. Something like:

function preload(){
var imageUrls = ["img1.jpg","img2.jpg","img3.jpg"];
var images = [];
for(var i=0;i<imageUrls.length;i++){
var image = new Image();
image.src = imageUrls[i];
images.push(image);
}
}

That you'd call that function during pageLoad(). Setting the 'src' of the image object should cause the browser to start downloading that image.


Nice,

I would like to try that, but I am having a problem converting this to VB. Can anyone convert this?Huh?


No, i'ts javascript.


Ahh, makes sense now.

Thanks.

Monday, March 26, 2012

pre-populating a modalpopupextender

Hi All,

I am using a modalpopupextender control on a form. The popup is actually a panel as opposed to another seperate from. To date the method for working like this has worked fine, however I have never had areason to pre-populate the popup. This time I do and now I have a problem.

My main form displays items based on a user selection. At the bottom of the page they are allowed to add or remove items so for this we want to pre-populate the popup before displaying it. To keep things simple for the moment I've just placed a label on my panel that is part of the popup. when the user has made a selection on the main page, I set the label ready for when the user may decide to use the popup. The probem is that when the popup is displayed, the label hasn't got the value. To help understand what I'm doing here's some of my code.

<cc1:ModalPopupExtender ID="mpeModifyRelationships" runat="server" PopupControlID="ModifyRelationships" TargetControlID="btnFake" BackgroundCssClass="modalBackground" CancelControlID="RelationshipCancelButton" ></cc1:ModalPopupExtender><script type="text/javascript">function showRelationShipPopup(){$get('<%=ModifyRelationships.ClientID%>').className = "modalpopup";$find('<%=mpeModifyRelationships.ClientID%>').show();return false;}</script>

then also on the main page I have this button. This makes the call to the above function causing the popup to display.

<asp:Button ID="btnModify" runat="server" Text="Modify Relationship" Enabled="false" OnClientClick="return showRelationShipPopup()" />
Now my popup is made up thus:
 
 <asp:Panel ID="ModifyRelationships" runat="server" Height="500px" Width="1000px" BackColor="White" BorderStyle="Solid" CssClass="hidden" ScrollBars="Auto"> <table> <tr> <td>Attribute: <asp:Label ID="lblAttribute" runat="server" Text=""></asp:Label></td> <td>Component: <asp:Label ID="lblComponent" runat="server" Text=""></asp:Label></td> <td>Sub-Component: <asp:Label ID="lblSubComponent" runat="server" Text=""></asp:Label></td> </tr> </table> Associated Sors <div style="margin-left: 20px; margin-right: 20px" class="box"> <asp:ListBox ID="lstBoxAssSors" SelectionMode="single" runat="server" Height="120px" Width="936px"></asp:ListBox> </div> <asp:Button ID="RelationshipCancelButton" runat="server" Text="Cancel" CausesValidation="False" Width="80px" /> </asp:Panel>
So behind the scenes I'm setting lblAttribute.text, but when the button is pressed the popup displays, but the text is empty.

See this thread:http://forums.asp.net/p/1149333/1870370.aspx

-Damien

Preserving the scroll position of a treeview in an update panel

Hi There,

I have a treeview control in a panel with scrollbars. I want to preserve the scroll position and I have this code which works absolutely fine in firefox, but it doesn't in IE. Can somebody please get back to me, if you have experienced this problem and solved it.

Also I noticed that if I put an alert (commented), it works fine, which is absolutely weird.

Thanks a lot!!

<scripttype="text/javascript">

var scrollTop;

Sys.WebForms.PageRequestManager.getInstance().add_beginRequest(BeginRequestHandler);

Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequestHandler);

function BeginRequestHandler(sender, args)

{

var elem = document.getElementById('<%= treePanel.ClientID %>');

scrollTop=elem.scrollTop;

}

function EndRequestHandler(sender, args)

{

//alert(scrollTop);

var elem = document.getElementById('<%= treePanel.ClientID %>');

elem.scrollTop = scrollTop;

}

</script>

I noticed one more weird thing. I have roles set up on this application. If a user is in the admin role, this works fine. But if the user is not in that role, then the scrolling is not preserved, whenever a node is selected. I have absolutely no idea why this is happening..This is the case only in IE. Firefox has no problem at all.

Any suggestions are greatly appreciated..

Thanks a lot!!


Change:

Sys.WebForms.PageRequestManager.getInstance().add_endRequest(EndRequestHandler);

to:

Sys.WebForms.PageRequestManager.getInstance().add_pageLoaded(PageLoadedHandler);

and change the name of your function. endRequest happens when control has been returned to the browser, but everything may not have been rendered on the page. Your code is getting ahead of itself.


Thanks a lot for your suggestion. It still doesn't work...thisis what I have..

<scripttype="text/javascript">

var scrollTop;

Sys.WebForms.PageRequestManager.getInstance().add_beginRequest(BeginRequestHandler);

Sys.WebForms.PageRequestManager.getInstance().add_pageLoaded(PageLoadedHandler);

function BeginRequestHandler(sender, args)

{

var elem = document.getElementById('<%= treePanel.ClientID %>');

scrollTop=elem.scrollTop;

}

function PageLoadedHandler(sender, args)

{

var elem = document.getElementById('<%= treePanel.ClientID %>');

elem.scrollTop = scrollTop;

}

</script>


IE evidently has difficult with scrollTop under certain DOCTYPE definitions.

Replace elem.scrollTop = scrollTop; with

elem.scrollTo(0,scrollTop);


Unfortunately, scrollTo is not recognized in IE 7. I am not sure about IE 6.

As I have mentioned earlier, there is one more weird thing. I have roles set up on this application. If a user is in the admin role, this (script with scrollTop) works fine. But if the user is not in that role, then the scrolling is not preserved, whenever a node is selected. I have absolutely no idea why this is happening..This is the case only in IE. Firefox has no problem at all.

Thanks.


http://www.eggheadcafe.com/tutorials/aspnet/7dd57635-0587-42ba-ae73-f52449e653bf/aspnet-ajax-maintain-scr.aspx

http://forums.asp.net/p/1150033/1873660.aspx

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

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

Usually People loves to maintain the scroll postiion. But requirment is reverse, Here is the trick, create an script tag after the scriptmanager and put the following lines:

<script type="text/javascript">var prm = Sys.WebForms.PageRequestManager.getInstance();prm.add_beginRequest(beginRequest);function beginRequest(){ prm._scrollPosition = null;}</script> 

Let me know if this helpful to you


I got this working from the links in the second link you have posted..

I have onscroll="javascript:saveScroll();" on the panel and..

<script type='text/javascript'>
var scrollLeft = 0;

function setScroll()
{
if(document.getElementById('<%= Panel1.ClientID %>').scrollLeft != scrollLeft)
{
document.getElementById('<%= Panel1.ClientID %>').scrollLeft = scrollLeft;
}
}

function saveScroll()
{
scrollLeft = document.getElementById('<%= Panel1.ClientID %>').scrollLeft;
}
</script>

The condition forces the scrolling..

Thanks a lot.

Also thanks to Mr. Budda for his suggestions...

Prevent CHECKBOX in Update Panel

Hi there,i'm using CHECKBOX in Gridview Template Panel, and My Gridview is under UpdatePanel. The update panel will be refresh every 3 second using timer. how to prevent CHECKBOX from 'unchecking' when the user have already check the CHECKBOX ?Thanks.

Hi,

can you identify if it is due to slowly loading update panel or checkbox just loses its checked state on postback?

You can place just a button anywher eon the page (disable your timer before) and see if checkbox loses its checked value when you click this button.

-yuriy


The CHECKBOX just loses its checked state. I dont think palce a button anywhere is the solution for the application, since it'll have so much button. any ideas ?Thanks.

Hi,

an approach would be saving the checked boxes in an hidden field in the page. When a postback occurs, you parse the hidden field and extract the info about the checked boxes.

Since the GridView might be bound to different data each time, you have to associate an ID to each checkbox. The ID might be that of a database row, for example.

Then, when you're binding the GridView, you check whether the ID is in the list of checked boxes. If it is, you select the corresponding checkbox.

Sounds little complicated, but it should work.

Prevent Modal Popup from Moving on Async Postback?

I have a draggable a panel with a ModalPopupExtender with an UpdatePanel inside it. Whenever I have an asynchronous postback run, the popup "jumps" back to to the center of the screen. Ideally it would stay in whatever position it is currently in, as the jump is jarring to the user experience.

Anyone know a way to avoid this?

Thanks!

Hi MWB,

To troubleshoot this issue, we really need the source code to reproduce the problem, so that we can investigate the issue in house. It is not necessary that you send out the complete source of your project. We just need a simplest sample to reproduce the problem. You can remove any confidential information or business logic from it.

Best regards,

Jonathan


Hi Jonathan -

Thanks very much for responding. I put together an extremely simple (and rather ugly, so forgive me) website project that reproduces the jumping modal popup behavior. Please let me know if you have any thoughts or questions. Since I can't directly upload the project files, the code is below.

Thanks again!

-Matthew

Default.aspx

<%@. Page Language="C#" AutoEventWireup="true" CodeFile="Default.aspx.cs" Inherits="_Default" %>
<%@. Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="cc1" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
<style>
*
{
font-family: Verdana, Helvetica, San-Serif;
}

.popupButton
{
font-weight: bold;
color: #C00;
}

.modalPopupBackground
{
background-color: #CCC;
filter: alpha(opacity=60);
opacity: 0.6;
}

.windowTitle
{
border: solid 2px #9CF;
background-color: #369;
color: #FFF;
font-size: 16px;
text-align: center;
padding: 10px 10px 10px 10px;
}

.window
{
width: 400px;
border: solid 2px #036;
background-color: #FFF;
padding: 5px 5px 5px 5px;
}

.windowContent
{
text-align: center;
margin: 10px 10px 10px 10px;
}
</style>
</head>
<body>
<form id="form1" runat="server">
<asp:ScriptManager ID="ScriptManager1" runat="server" /
<h1>Click this button</h1>
<asp:Button ID="Button_OpenPopup" runat="server" Text="Open Modal Popup" CssClass="popupButton" /
<div>
<h4>Junk text to allow dragging of Modal Popup</h4>
<p>
Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Phasellus vehicula nisi vitae elit. Vivamus metus diam, dignissim in, vehicula vitae, ultrices a, dui. Maecenas nec eros vel lacus gravida nonummy. Donec laoreet, metus vel interdum sodales, pede augue iaculis nunc, et venenatis sem mi sed elit. Donec arcu. Praesent nec magna. Nunc egestas lectus ac quam. Quisque in justo non tortor luctus faucibus. Fusce mattis dignissim diam. Phasellus gravida risus vel magna. Mauris commodo felis nec metus. Cras commodo euismod ante. Donec consectetuer nisl vitae nulla. Nam aliquet. Mauris semper velit id orci. Suspendisse elementum, pede et dictum molestie, mi ante pulvinar metus, ut varius massa dui et diam. Integer dictum fermentum ipsum. Nunc quis odio. Aenean vitae tellus.
</p>
<p>
In elit lectus, fermentum ac, fringilla accumsan, aliquam in, turpis. Praesent tempus sagittis augue. Aenean leo lectus, mattis ultricies, interdum sed, luctus ac, ligula. In hac habitasse platea dictumst. Vivamus placerat. Fusce turpis enim, tempor tempor, luctus at, bibendum id, sapien. Morbi feugiat ante eu eros. Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Proin sed felis. Duis sit amet justo. Vivamus eu diam ac dui bibendum tempus. Vivamus quis neque sit amet felis rutrum tristique.
</p>
<p>
Pellentesque adipiscing accumsan est. Sed dignissim arcu nec orci. Sed euismod diam. Donec at tellus. Suspendisse mauris neque, pharetra et, pretium vitae, blandit ut, pede. Vestibulum aliquet, nisi eu varius congue, neque dolor ornare augue, ut iaculis lacus urna eget justo. Vivamus urna. Suspendisse ipsum diam, blandit sit amet, semper ut, cursus eu, leo. Cras pede lorem, rhoncus vitae, posuere ac, ultrices at, lacus. Cras in augue quis purus ultrices sollicitudin. Nam congue, magna id sodales suscipit, tortor tellus ullamcorper metus, blandit iaculis nunc eros id augue. Nam posuere erat quis est. Nunc porta leo et lorem. Nam cursus massa et arcu. Proin augue diam, blandit ut, imperdiet a, elementum nec, purus. Pellentesque metus mauris, dignissim ac, dignissim et, venenatis in, massa. Curabitur eget dui sit amet erat tincidunt volutpat. Fusce vel nibh quis erat blandit posuere. Mauris porta, erat sit amet tincidunt commodo, augue lectus porttitor nulla, nec lobortis lacus elit ut elit. Cras feugiat posuere justo.
</p>
<p>
Cras a velit id massa ornare commodo. Donec egestas. Vestibulum sed felis. Etiam aliquam, tellus sit amet consectetuer bibendum, dui ante volutpat ligula, at semper lacus tellus a lorem. Sed et elit. Integer nisi purus, suscipit ac, nonummy nec, placerat eget, diam. Nullam sodales. Quisque erat pede, ultrices non, cursus ut, euismod vel, sem. In hac habitasse platea dictumst. Ut sit amet est. Nulla pellentesque. Quisque non dolor. Vestibulum mi arcu, accumsan ac, ullamcorper mollis, dignissim eu, urna. Vestibulum metus quam, congue eget, tempus quis, pellentesque ac, eros. Suspendisse risus lectus, interdum nec, tristique ut, auctor eu, urna. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Etiam ac mi. Sed eget arcu. Curabitur eu libero sit amet odio fringilla pharetra. Aenean arcu.
</p>
<p>
Donec malesuada. Phasellus sapien risus, tristique sit amet, varius id, iaculis sit amet, purus. Morbi egestas risus et turpis. Curabitur quis quam. Vestibulum tortor sem, feugiat id, laoreet et, egestas at, metus. Aenean pellentesque tellus sed metus. Pellentesque habitant morbi tristique senectus et netus et malesuada fames ac turpis egestas. Phasellus lacinia tempor erat. Vestibulum pharetra, sem vel porttitor lobortis, libero erat ultricies nulla, sed suscipit justo lorem vel nisi. Sed at sapien. Maecenas vestibulum elementum odio. Duis sagittis, diam vel posuere egestas, sapien lorem vulputate metus, faucibus rhoncus diam nulla sed est. Mauris imperdiet. Nulla sagittis. Aliquam velit arcu, facilisis in, tempus vel, hendrerit in, dolor. Ut lacinia est non neque nonummy ullamcorper.
</p>
<p>
*** sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Sed sit amet orci eu neque imperdiet imperdiet. Phasellus blandit mauris nonummy urna. Phasellus lacinia vestibulum felis. Fusce ullamcorper egestas sem. Donec auctor, lacus nec vulputate convallis, nunc purus vehicula erat, vitae blandit purus mi at lectus. Suspendisse tincidunt. Donec id justo. Sed eros augue, lobortis non, rhoncus quis, fermentum porta, risus. Pellentesque egestas condimentum quam. Nullam neque. Vivamus convallis tellus ut mauris. Phasellus luctus dapibus nibh. Phasellus pulvinar massa non nisi. Aenean malesuada euismod lacus. *** sociis natoque penatibus et magnis dis parturient montes, nascetur ridiculus mus. Fusce vitae tortor non diam pellentesque consectetuer. Curabitur tincidunt nunc sit amet turpis.
</p>
<p>
Donec est turpis, mattis in, scelerisque non, aliquet elementum, libero. Quisque mauris erat, rhoncus sit amet, tristique vitae, condimentum in, nunc. Vivamus quam nisl, tincidunt vel, consequat eu, sodales id, mauris. Nam eu eros id massa cursus pellentesque. Etiam quis metus in mi fringilla lacinia. Lorem ipsum dolor sit amet, consectetuer adipiscing elit. Suspendisse ac nisi. In hac habitasse platea dictumst. In hac habitasse platea dictumst. Sed sodales porttitor dolor. Vestibulum risus. Mauris augue augue, ultricies vitae, adipiscing in, elementum sit amet, nunc.
</p>
<p>
Pellentesque pulvinar dignissim quam. Donec sed justo et elit semper interdum. Duis nec leo ac urna pellentesque eleifend. Morbi consectetuer purus ut felis. Nulla euismod fermentum enim. Ut aliquet tellus at justo. Sed purus. Phasellus porttitor commodo ligula. Phasellus sem. Donec non orci. Donec in nibh in lorem lacinia sagittis. Aenean vestibulum dictum sem. Sed ligula. Maecenas pharetra laoreet velit. Nam vitae mauris nec tellus cursus tincidunt. Curabitur malesuada massa feugiat nisl. Maecenas dapibus aliquam diam. Pellentesque ac dolor. Proin sagittis ultricies dui.
</p>
<p>
Ut vel orci sagittis odio tempor porta. Cras vitae nunc. In sollicitudin pharetra sapien. Donec imperdiet. Aenean egestas dui a mi. Cras mauris velit, tincidunt sed, tempor et, sollicitudin et, arcu. Quisque turpis lorem, hendrerit quis, blandit quis, convallis eget, pede. Etiam lacus lectus, molestie vitae, egestas pellentesque, dapibus sit amet, est. Suspendisse nibh dolor, bibendum a, sollicitudin sollicitudin, pulvinar sed, magna. Proin in nunc. Praesent blandit tempus magna. Aliquam erat volutpat. Morbi mattis. Nunc pretium laoreet ante. Integer eros nisi, luctus sed, commodo quis, tincidunt quis, ipsum. Morbi magna dolor, tempor id, sagittis faucibus, adipiscing at, dui. Sed ornare, orci non lobortis viverra, nibh enim auctor lorem, at bibendum lacus massa et eros. Phasellus luctus. Suspendisse volutpat nunc eget augue.
</p>
<p>
Curabitur vulputate. Donec nunc lorem, porta accumsan, pretium nec, scelerisque aliquet, ligula. Aenean eleifend aliquam lorem. Quisque facilisis. Nullam porta. Vivamus congue dapibus libero. Vestibulum placerat bibendum enim. Sed diam eros, lobortis vel, varius a, pretium et, nibh. Nulla nisi dui, malesuada eu, lobortis tincidunt, mattis nec, leo. Proin massa mauris, interdum et, elementum vitae, ornare ut, lorem. Fusce erat massa, dignissim sed, viverra sit amet, euismod in, magna. Donec consectetuer porta odio.
</p>
</div
<asp:Panel ID="Panel_PopupWindow" runat="server" CssClass="window">
<asp:Panel ID="Panel_Panel_PopupWindowTitle" runat="server" CssClass="windowTitle">
<p><strong>Drag Me</strong></p>
<asp:Button ID="Button_ClosePopup" runat="server" Text="Close Modal Popup" />
</asp:Panel
<asp:Panel ID="Panel_PopupWindowContent" runat="server" CssClass="windowContent">
<asp:UpdatePanel ID="UpdatePanel_PopupWindowContent" runat="server" UpdateMode="Conditional" ChildrenAsTriggers="True">
<ContentTemplate>
<div style="text-align: left;">
<p>How to reproduce the jumping Modal Popup issue:</p>
<ol>
<li>
Drag the popup using the blue box that says "Drag Me" above
so that the popup is no longer in the default centered location
</li>
<li>Click "Generate Asynchronous Postback"</li>
<li>
Note how the popup "jumps" back to the default
center location. This is the behavior I wish to avoid.
</li>
</ol>
</div>
<p><strong>Any ideas? Thanks!</strong></p>
<p><asp:Literal ID="Literal_Test" runat="server" /></p>
<asp:Button runat="server" Text="Generate Asynchronous Postback" OnClick="ShowDate" />
</ContentTemplate>
</asp:UpdatePanel>
</asp:Panel>
</asp:Panel>
<ajaxToolkit:ModalPopupExtender ID="ModalPopupExtender" runat="server" EnableViewState="true" TargetControlID="Button_OpenPopup" PopupControlID="Panel_PopupWindow"
CancelControlID="Button_ClosePopup" PopupDragHandleControlID="Panel_Panel_PopupWindowTitle" BackgroundCssClass="modalPopupBackground" />
</form>
</body>
</html>

Default.aspx.cs

using System;
using System.Web.UI.WebControls;
public partialclass _Default : System.Web.UI.Page
{
protected void ShowDate(object sender, EventArgs e)
{
Literal_Test.Text = System.DateTime.Now.ToString();
}
}

Web.Config

<configuration>
<configSections>
<sectionGroup name="system.web.extensions" type="System.Web.Configuration.SystemWebExtensionsSectionGroup, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
<sectionGroup name="scripting" type="System.Web.Configuration.ScriptingSectionGroup, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
<section name="scriptResourceHandler" type="System.Web.Configuration.ScriptingScriptResourceHandlerSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="MachineToApplication"/>
<sectionGroup name="webServices" type="System.Web.Configuration.ScriptingWebServicesSectionGroup, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35">
<section name="jsonSerialization" type="System.Web.Configuration.ScriptingJsonSerializationSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="Everywhere"/>
<section name="profileService" type="System.Web.Configuration.ScriptingProfileServiceSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="MachineToApplication"/>
<section name="authenticationService" type="System.Web.Configuration.ScriptingAuthenticationServiceSection, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" requirePermission="false" allowDefinition="MachineToApplication"/>
</sectionGroup>
</sectionGroup>
</sectionGroup>
</configSections>
<system.web>
<pages>
<controls>
<add tagPrefix="asp" namespace="System.Web.UI" assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add namespace="AjaxControlToolkit" assembly="AjaxControlToolkit" tagPrefix="ajaxToolkit"/>
</controls>
</pages>
<compilation debug="true">
<assemblies>
<add assembly="System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add assembly="System.Design, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B03F5F7F11D50A3A"/>
<add assembly="System.Web.Extensions.Design, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31BF3856AD364E35"/>
<add assembly="System.Windows.Forms, Version=2.0.0.0, Culture=neutral, PublicKeyToken=B77A5C561934E089"/>
</assemblies>
</compilation>
<httpHandlers>
<remove verb="*" path="*.asmx"/>
<add verb="*" path="*.asmx" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add verb="*" path="*_AppService.axd" validate="false" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" validate="false"/>
</httpHandlers>
<httpModules>
<add name="ScriptModule" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
</httpModules>
</system.web>
<system.web.extensions>
<scripting>
<webServices>
</webServices>
</scripting>
</system.web.extensions>
<system.webServer>
<validation validateIntegratedModeConfiguration="false"/>
<modules>
<add name="ScriptModule" preCondition="integratedMode" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
</modules>
<handlers>
<remove name="WebServiceHandlerFactory-Integrated"/>
<add name="ScriptHandlerFactory" verb="*" path="*.asmx" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add name="ScriptHandlerFactoryAppServices" verb="*" path="*_AppService.axd" preCondition="integratedMode" type="System.Web.Script.Services.ScriptHandlerFactory, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
<add name="ScriptResource" preCondition="integratedMode" verb="GET,HEAD" path="ScriptResource.axd" type="System.Web.Handlers.ScriptResourceHandler, System.Web.Extensions, Version=1.0.61025.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
</handlers>
</system.webServer>
</configuration>

Hi MWB,

Thanks for your sample.I have reproduced your problem with your sample.

Based on my research and testing, I'm afraid that what your want is not achievable in your case.It will automaticlly reset to orignal position when a post occured.Thanks.

Best regards,

Jonathan

preventing the tab index change if certain conditions exist

Hello,

I have a form with a tab panel control

Tab container name (client id) : Tabs

I would like to know how to set and prevent the tab from moving from index 0 if the request.querystring("pid") is empty or null.

Here is my current javascript:

<scripttype="text/javascript">function PanelClick(sender, e) {

var mpid = gup('pid');

if (mpid=="") {

SetActiveTab("Tabs",0);

}

}

function ActiveTabChanged(sender, e) {var mpid = gup('pid');

if (mpid=="") {

alert("Please choose a page or create a new page first");

returnfalse;

}

}

function SetActiveTab(tabControl, tabNumber)

{

var ctrl = $find(tabControl);

ctrl.set_activeTab(ctrl.get_tabs()[tabNumber]);

}

function gup( name ){name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");

var regexS ="[\\?&]"+name+"=([^&#]*)";

var regex =new RegExp( regexS );

var results = regex.exec( window.location.href );

if( results ==null )return"";

else

return results[1];}

</script>

I guess all I need is the javascript reference to the active tab...

can anyone help me with this?

Ok, through a little more research, I found out how to navigate or prevent navigation of the tabs control via javascript:

Here's the code

<scripttype="text/javascript">

/

function ActiveTabChanged(sender, e) {

var mpid = gup('pid'); // get the querystring in the url by calling the gup function below... good little snippet for querystrings in javascript.

var activeTab = $get("Tabs"); // gets the element by the id of "Tabs" and defines the control variable activeTab.

activeTab.value = sender.get_activeTabIndex(); // gets the active tab index of the control.

if (mpid=="" && activeTab.value!=0) { // if the conditions aren't right then don't allow the user to navigate to any other tab.

alert("Please choose a page or create a new page first"); // alert the user.

SetActiveTab("Tabs",0); // sets the active tabreturnfalse; // doesn't allow the process to go to another tab.

}

}

function SetActiveTab(tabControl, tabNumber)

{

var ctrl = $find(tabControl);

ctrl.set_activeTab(ctrl.get_tabs()[tabNumber]);

}

function gup( name ){name = name.replace(/[\[]/,"\\\[").replace(/[\]]/,"\\\]");

var regexS ="[\\?&]"+name+"=([^&#]*)";

var regex =new RegExp( regexS );

var results = regex.exec( window.location.href );

if( results ==null )return"";

else

return results[1];}

</script>

I hope that the scripts above can help someone else.

Print Problem With Updatepanel

HI,

Iam facing problem with update panel.I has a reportviewer and a updatepanel.Updatepanel consists of Reportviewer.Whenever i click on Print Option of Reportviewer,Postback ocurs But no print dialog appears.(So no print).How to Print report when it is is in updatepanel.

When i remove updatepanel Print wrks .But when i keep it in updatepanel NO PRINT ocurs

Plz help ...It is Very urgent

With regards,

Mahender

Any chance you can post the code?
<asp:UpdatePanelID="ReportViewerUpdatePanel"runat="server"UpdateMode="Conditional "ChildrenAsTriggers="true"><ContentTemplate><asp:UpdateProgressID="ReportViewerUpdateProgress"runat="server"><ProgressTemplate><divstyle="display:block; "><center>

Loading ...

<imgalt=""src="Images/Updatepanel/loading.gif"/></center></div></ProgressTemplate></asp:UpdateProgress>

<rsweb:ReportViewerID="ReportViewer1"runat="server"BackColor="WhiteSmoke"ProcessingMode="Remote"Height="100%"ShowBackButton="true"ShowFindControls="false"DocumentMapWidth="50%"ShowParameterPrompts="false"ShowRefreshButton="true"ShowReportBody="false"ShowPromptAreaButton="true"ShowToolBar="true"ShowExportControls="true"ShowZoomControl="false"Width="100%"EnableTheming="true"ShowCredentialPrompts="true"DocumentMapCollapsed="true"LinkActiveColor="Black"LinkActiveHoverColor="Chocolate"LinkDisabledColor="Gray"ExportContentDisposition="AlwaysInline"EnableViewState="true"ShowPrintButton="true"><ServerReportReportServerUrl="http://localhost/ReportServer$SQL"/></rsweb:ReportViewer>

</ContentTemplate><Triggers><asp:AsyncPostBackTriggerControlID="DropdownMenuLinkButton"EventName="Click"/>

</Triggers>

</asp:UpdatePanel>

Incode behind of One event.In my case Buttonclick

this is Code

ReportViewer1.ProcessingMode =

ProcessingMode.Remote;Uri u =newUri("http://localhost/ReportServer$SQL");

ReportViewer1.ServerReport.ReportServerUrl = u;

ReportViewer1.ServerReport.ReportPath =

"/thad/Report1";

ReportViewer1.AsyncRendering =

true;

ReportViewer1.ShowBackButton =

true;

ReportViewer1.ShowFindControls =

true;

ReportViewer1.ShowRefreshButton =

true;

ReportViewer1.ShowPrintButton =

true;

ReportViewer1.ShowReportBody =

true;

ReportViewer1.ShowPromptAreaButton =

true;

ReportViewer1.ShowToolBar =

true;// ReportViewer1.ShowExportControls = true;

ReportViewer1.ShowZoomControl =

true;

ReportViewer1.ToolTip =

"Report Viewer";

ReportViewer1.Width =

Unit.Percentage(100);

ReportViewer1.Height =

Unit.Percentage(100);//ReportViewer1.EnableTheming = true;

ReportViewer1.ShowCredentialPrompts =

true;

ReportViewer1.LinkActiveColor = System.Drawing.

Color.Black;

ReportViewer1.LinkActiveHoverColor = System.Drawing.

Color.Chocolate;

ReportViewer1.LinkDisabledColor = System.Drawing.

Color.Gray;

ReportViewer1.ShowPrintButton =

true;
<asp:UpdatePanelID="ReportViewerUpdatePanel"runat="server"UpdateMode="Conditional "ChildrenAsTriggers="true"><ContentTemplate><asp:UpdateProgressID="ReportViewerUpdateProgress"runat="server"><ProgressTemplate><divstyle="display:block; "><center>

Loading ...

<imgalt=""src="Images/Updatepanel/loading.gif"/></center></div></ProgressTemplate></asp:UpdateProgress>

<rsweb:ReportViewerID="ReportViewer1"runat="server"BackColor="WhiteSmoke"ProcessingMode="Remote"Height="100%"ShowBackButton="true"ShowFindControls="false"DocumentMapWidth="50%"ShowParameterPrompts="false"ShowRefreshButton="true"ShowReportBody="false"ShowPromptAreaButton="true"ShowToolBar="true"ShowExportControls="true"ShowZoomControl="false"Width="100%"EnableTheming="true"ShowCredentialPrompts="true"DocumentMapCollapsed="true"LinkActiveColor="Black"LinkActiveHoverColor="Chocolate"LinkDisabledColor="Gray"ExportContentDisposition="AlwaysInline"EnableViewState="true"ShowPrintButton="true"><ServerReportReportServerUrl="http://localhost/ReportServer$SQL"/></rsweb:ReportViewer>

</ContentTemplate><Triggers><asp:AsyncPostBackTriggerControlID="DropdownMenuLinkButton"EventName="Click"/>

</Triggers>

</asp:UpdatePanel>

Incode behind of One event.In my case Buttonclick

this is Code

ReportViewer1.ProcessingMode =

ProcessingMode.Remote;Uri u =newUri("http://localhost/ReportServer$SQL");

ReportViewer1.ServerReport.ReportServerUrl = u;

ReportViewer1.ServerReport.ReportPath =

"/thad/Report1";

ReportViewer1.AsyncRendering =

true;

ReportViewer1.ShowBackButton =

true;

ReportViewer1.ShowFindControls =

true;

ReportViewer1.ShowRefreshButton =

true;

ReportViewer1.ShowPrintButton =

true;

ReportViewer1.ShowReportBody =

true;

ReportViewer1.ShowPromptAreaButton =

true;

ReportViewer1.ShowToolBar =

true;// ReportViewer1.ShowExportControls = true;

ReportViewer1.ShowZoomControl =

true;

ReportViewer1.ToolTip =

"Report Viewer";

ReportViewer1.Width =

Unit.Percentage(100);

ReportViewer1.Height =

Unit.Percentage(100);//ReportViewer1.EnableTheming = true;

ReportViewer1.ShowCredentialPrompts =

true;

ReportViewer1.LinkActiveColor = System.Drawing.

Color.Black;

ReportViewer1.LinkActiveHoverColor = System.Drawing.

Color.Chocolate;

ReportViewer1.LinkDisabledColor = System.Drawing.

Color.Gray;

ReportViewer1.ShowPrintButton =

true;
<asp:UpdatePanelID="ReportViewerUpdatePanel"runat="server"UpdateMode="Conditional "ChildrenAsTriggers="true"><ContentTemplate><asp:UpdateProgressID="ReportViewerUpdateProgress"runat="server"><ProgressTemplate><divstyle="display:block; "><center>

Loading ...

<imgalt=""src="Images/Updatepanel/loading.gif"/></center></div></ProgressTemplate></asp:UpdateProgress>

<rsweb:ReportViewerID="ReportViewer1"runat="server"BackColor="WhiteSmoke"ProcessingMode="Remote"Height="100%"ShowBackButton="true"ShowFindControls="false"DocumentMapWidth="50%"ShowParameterPrompts="false"ShowRefreshButton="true"ShowReportBody="false"ShowPromptAreaButton="true"ShowToolBar="true"ShowExportControls="true"ShowZoomControl="false"Width="100%"EnableTheming="true"ShowCredentialPrompts="true"DocumentMapCollapsed="true"LinkActiveColor="Black"LinkActiveHoverColor="Chocolate"LinkDisabledColor="Gray"ExportContentDisposition="AlwaysInline"EnableViewState="true"ShowPrintButton="true"><ServerReportReportServerUrl="http://localhost/ReportServer$SQL"/></rsweb:ReportViewer>

</ContentTemplate><Triggers><asp:AsyncPostBackTriggerControlID="DropdownMenuLinkButton"EventName="Click"/>

</Triggers>

</asp:UpdatePanel>

Incode behind of One event.In my case Buttonclick

this is Code

ReportViewer1.ProcessingMode =

ProcessingMode.Remote;Uri u =newUri("http://localhost/ReportServer$SQL");

ReportViewer1.ServerReport.ReportServerUrl = u;

ReportViewer1.ServerReport.ReportPath =

"/thad/Report1";

ReportViewer1.AsyncRendering =

true;

ReportViewer1.ShowBackButton =

true;

ReportViewer1.ShowFindControls =

true;

ReportViewer1.ShowRefreshButton =

true;

ReportViewer1.ShowPrintButton =

true;

ReportViewer1.ShowReportBody =

true;

ReportViewer1.ShowPromptAreaButton =

true;

ReportViewer1.ShowToolBar =

true;// ReportViewer1.ShowExportControls = true;

ReportViewer1.ShowZoomControl =

true;

ReportViewer1.ToolTip =

"Report Viewer";

ReportViewer1.Width =

Unit.Percentage(100);

ReportViewer1.Height =

Unit.Percentage(100);//ReportViewer1.EnableTheming = true;

ReportViewer1.ShowCredentialPrompts =

true;

ReportViewer1.LinkActiveColor = System.Drawing.

Color.Black;

ReportViewer1.LinkActiveHoverColor = System.Drawing.

Color.Chocolate;

ReportViewer1.LinkDisabledColor = System.Drawing.

Color.Gray;

ReportViewer1.ShowPrintButton =

true;

Probblem with Menu control inside an update panel

Hi,

I have a master page with a script manager ,update panel and Content Palce Holder. in the default page which uses the masterpage I have added a menu control, textbox and a button. I have two problems which I have seen in the past in other versions of ajax. I have not coded anything other than just these controls on a page

1) I could click on button all day long and there is no java script error but as soon as I click on a menu item I get javascript error saying:

Line:221

Char:20

Error '0.cells' is null or not an object

code: 0

2) I can not get my CSS sheet work in my app theme for the background images. I have the following code in my CSS

.Menu1BackGround

{

background-image:url(/Images/Menu1_Background.bmp);

}

and I have assigned the it to the menu. Nothing happens as if it does not recognize the image path. I could add the background:black to the code and it works fine for the color but not the image. I am not sure if thisis because of the same problem.

Any body have any ideas?

Thanks

Seehttp://ajax.asp.net/docs/overview/UpdatePanelOverview.aspx#UpdatePanelCompatibleControls. The Menu control is not supported inside an UpdatePanel.

I have been using this piece of javascript to go around the menu problem:

var oldMenu_HideItems = Menu_HideItems;if(oldMenu_HideItems){Menu_HideItems = function(items){if (!items || ((typeof(items.tagName) =="undefined") && (items instanceof Event))) { items = __rootMenuItem; }if(items && items.rows && items.rows.length == 0){ items.insertRow(0); }return oldMenu_HideItems(items);} }
I got it from the asp:menu javascript code and I hook it to "patch" the problem.
Adding it to a page where a menu resides makes the javascript error go away. 

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

HTH


Menu control is not compatable with AJAX.

I m also facing sme problem..

problem about Collapsed proterty of CollapsiblePanelExtender

i set Collapsed="true" and i found that the target panel was first Expanded then Collapsed with a visual effect after the page loaded.

i hope the panel keeps Collapsed without any visual effect.

anyone please helps me.Crying

Here's my code to accomplish that. Hope it helps.

<asp:Image ID="Image2" runat="server" AlternateText="(Got Your PartNumber? Quick Order Here)"
ImageUrl="~/images/collapse.jpg" />
Quick Order<br />
<asp:Label ID="lblReplacementPart" runat="server" ForeColor="Red"></asp:Label>

<asp:Panel ID="PanelQuickOrder" runat="server">
<table class="contentText">
<tr>
<td colspan="2" nowrap="nowrap">
Enter Part Number:<br />
<asp:TextBox ID="txtPartNumber" runat="server"></asp:TextBox><br />
<i>format ####-######</i>
</td>
</tr>
<tr>
<td colspan="2">
Qty: <asp:TextBox ID="txtQOQty" runat="server" Width="25" Text="1"></asp:TextBox><br />
</td>
</tr>
<tr>
<td align="right" colspan="2">
<asp:Button ID="btnQO_AddCart" runat="server" Text="Add to Cart" OnClick="btnQO_AddCart_Click" /></td>
</tr>
</table>
</asp:Panel>

<ajax:CollapsiblePanelExtender ID="cpe2" runat="Server" AutoCollapse="False" AutoExpand="False"
CollapseControlID="Image2" Collapsed="True" CollapsedImage="~/images/expand.jpg"
CollapsedSize="2" CollapsedText="Got PartNumber? Use Quick Order" ExpandControlID="Image2"
ExpandDirection="Vertical" ExpandedImage="~/images/collapse.jpg" ExpandedSize="150"
ExpandedText="Got PartNumber? Use Quick Order" ImageControlID="Image2" ScrollContents="false"
SuppressPostBack="true" TargetControlID="PanelQuickOrder">
</ajax:CollapsiblePanelExtender>


Doraeimo,

I am actually having the same issue as you. if you watch the video on the collapsible panel you will notice that he uses a CssClass that sets the height of the content panel to 0px. this is suposed to "hide" the content panel at page load. it works very nicely for him in the video, so maybe it will work for you as well. However; setting the height directly in the panel definition, or in a cssclass does not do the trick for me. you should at least give it a try to see if that works for you !

Sorry to piggyback on your post here. but since it works in the video it may work for you, and maybe some one has some ideas as to why setting the height for me doesnt work.

Saturday, March 24, 2012

Problem adding Atlas to an existing site

I have created a test atlas site and successfully used the update panel with some dropdown lists. Now I want to incorporate Atlas into an existing web site. I created a test page in the existing web site and recreated my test page in the existing site. The Atlas components to not seem to work... instead of an ajax update it is doing a full postback.

Here are the things I've checked:

- Atlas dll is included in bin
- Web.config file is updated and matches the test site config exactly
- Test web page is exactly the same as on the test site
- The .asbx extension is registered correctly
- The web site is configured for .Net 2.0

I'm not even sure how to figure out what else is going on here. Any other suggestions or things I can look at here? Thanks!

hello.

have you created a simple page on that site? if so, post it here so that we can see if there's anything wrong with it or if it's a configuration problem...


I have done a simple page on the test site (which works) and the exact same page in the existing site (which doesn't work) so I'm not sure the code provides any value. But here is another clue. When I add the trigger to the update panel through the designer, switch to code view, and then back to designer I get an "error creating control"

It says: Triggers could not be initialized. Triggers could not be added to the collection. Details: Object does not match target type.

Here is the web page code:

<%@. Page Language="C#" AutoEventWireup="true" CodeFile="IssueTest.aspx.cs" Inherits="ProjectTrack_IssueTest" %><%@. Register Assembly="AtlasControlToolkit" Namespace="AtlasControlToolkit" TagPrefix="cc1" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" ><head id="Head1" runat="server"> <title>Untitled Page</title> </head><body> <form id="form1" runat="server"> <atlas:ScriptManager ID="ScriptManager1" runat="server" EnablePartialRendering="true"> </atlas:ScriptManager> <asp:DropDownList ID="ClientsDDL" runat="server" DataSourceID="RDI_DB" DataTextField="CO_NAME" DataValueField="Client_ID" OnSelectedIndexChanged="ClientsDDL_SelectedIndexChanged" AutoPostBack=true> </asp:DropDownList><atlas:UpdatePanel runat="server" ID="UpdatePanel1" Mode="Conditional"> <Triggers> <atlas:ControlEventTrigger ControlID="ClientsDDL" EventName="SelectedIndexChanged" /> </Triggers> <ContentTemplate> <asp:DropDownList ID="ProjectsDDL" runat="server" DataTextField="PROJ_NAME" DataValueField="PROJECT_NO" AppendDataBoundItems=true AutoPostBack="True" OnSelectedIndexChanged="ProjectsDDL_SelectedIndexChanged"><asp:ListItem>Select a client</asp:ListItem> </asp:DropDownList> </ContentTemplate> </atlas:UpdatePanel> <asp:DropDownList ID="PhaseDDL" runat="server" DataTextField="DESCRIPTION" DataValueField="PHASE" AppendDataBoundItems=true AutoPostBack="True"><asp:ListItem>Select a project</asp:ListItem> </asp:DropDownList> <asp:DropDownList ID="TaskDDL" runat="server" DataTextField="TASK" DataValueField="TASK" AppendDataBoundItems=true><asp:ListItem>Select a phase</asp:ListItem> </asp:DropDownList> <asp:SqlDataSource ID="RDI_DB" runat="server" ConnectionString="<%$ ConnectionStrings:RDI_DevelopmentConnectionString%>" SelectCommand="SELECT [Client_ID], [CO_NAME] FROM [CLIENTS]"></asp:SqlDataSource> <asp:SqlDataSource ID="ProjectListDB" runat="server" ConnectionString="<%$ ConnectionStrings:RDI_DevelopmentConnectionString%>" SelectCommand="SELECT [PROJECT_NO], [PROJ_NAME] FROM [PROJ_NO] WHERE ([CLIENT_ID] = @.CLIENT_ID)"> <SelectParameters> <asp:ControlParameter ControlID="ClientsDDL" Name="CLIENT_ID" PropertyName="SelectedValue" Type="Int32" /> </SelectParameters> </asp:SqlDataSource> <asp:SqlDataSource ID="PhaseListDB" runat="server" ConnectionString="<%$ ConnectionStrings:RDI_DevelopmentConnectionString%>" SelectCommand="SELECT [PHASE], [DESCRIPTION] FROM [PHASE] WHERE (([CLIENT_ID] = @.CLIENT_ID) AND ([PROJECT_NO] = @.PROJECT_NO)) ORDER BY [DESCRIPTION]"> <SelectParameters> <asp:ControlParameter ControlID="ClientsDDL" Name="CLIENT_ID" PropertyName="SelectedValue" Type="Int32" /> <asp:ControlParameter ControlID="ProjectsDDL" Name="PROJECT_NO" PropertyName="SelectedValue" Type="Int32" /> </SelectParameters> </asp:SqlDataSource> <asp:SqlDataSource ID="TasksListDB" runat="server" ConnectionString="<%$ ConnectionStrings:RDI_DevelopmentConnectionString%>" SelectCommand="SELECT [TASK], [DESCRIPTION] FROM [TASK] WHERE ([PHASE] = @.PHASE)"> <SelectParameters> <asp:ControlParameter ControlID="PhaseDDL" Name="PHASE" PropertyName="SelectedValue" Type="Int32" /> </SelectParameters> </asp:SqlDataSource>   </form></body></html>

hello.

tell me something: can you run the following code with success:

<atlas:scriptmanager runat="server" id="manager" enablepartialrendering="true" />

<atlas:updatepanel runat="server" id="panel">
<contenttemplate>
<asp:button runat="server" Text="Submit" />
<%=DateTime.Now.ToString() %>
</contenttemplate>
</atlas:updatepanel>


Same results... in my existing web site it causes a postback. In my test web site it does an ajax update (no postback). Does that tell you anything? Thanks.

hello again.

one more question:

open the previous page on the browser, right click on it and look at the source code. find the script element that is used to load the js file (you might have several elements that user the webresource.axd on the page; in this case, you'll have to repeat it to all the items you find). copy the address that is in the src attribute of the script element and add it to the url of the page you have in the browser (you'll probably have to delete a portion of the url before adding the value you've copied from the source file).

can you get the file? ie, can you get the js atlas file? if you can't get the file (you should see the tradidional save dialog), then you have a iis configuration problem...

Problem by using adrotator and timer control for an atlas project

Hello.
I want to show the advertisements without page posting. I have an adrotator,an xml file,timer control,and an update panel. When I run the project only one advertisement is shown on the page then the page is blank.
My aspx.pages codes:

<div>
<atlas:ScriptManager ID="ScriptManager1" runat="server" EnablePartialRendering="True">
</atlas:ScriptManager>
<atlas:TimerControl ID="TimerControl1" Interval="2000" runat="server" />
<atlas:UpdatePanel ID="UpdatePanel1" runat="server" >
<ContentTemplate>
<asp:AdRotator ID="AdRotator1" runat="server" AdvertisementFile="~/ads.xml" />
</ContentTemplate>
</atlas:UpdatePanel>
</div
and ads.xml

<?xml version="1.0" encoding="utf-8" ?
<Advertisements>
<Ad>
<ImageUrl>Images/Book1.jpg</ImageUrl>
<NavigateUrl>http://www.Amazon.com/Book1.aspx</NavigateUrl>
<AlternateText>Book1</AlternateText>
<Impressions>2</Impressions>
<Keyword>Book</Keyword>
</Ad
<Ad>
<ImageUrl>Images/Book2.jpg</ImageUrl>
<NavigateUrl>http://www.Amazon.com/Book2.aspx</NavigateUrl>
<AlternateText>Book2</AlternateText>
<Impressions>2</Impressions>
<Keyword>Book</Keyword>
</Ad
<Ad>
<ImageUrl>Images/Book3.jpg</ImageUrl>
<NavigateUrl>http://www.Amazon.com/Book3.aspx</NavigateUrl>
<AlternateText>Book3</AlternateText>
<Impressions>3</Impressions>
<Keyword>Book</Keyword>
</Ad
<Ad>
<ImageUrl>Images/Book4.jpg</ImageUrl>
<NavigateUrl>http://www.Amazon.com/Book4.aspx</NavigateUrl>
<AlternateText>Book4</AlternateText>
<Impressions>3</Impressions>
<Keyword>Book</Keyword>
</Ad
</Advertisements
can you help me?The timer isn't in the UpdatePanel so you need to add the Tick event as a trigger.
Thanks for your reply but I tried it before too.
my aspx pages codes:

<atlas:ScriptManager ID="ScriptManager1" runat="server" EnablePartialRendering="True" >
<ErrorTemplate>
There was an error processing your action.<br />
<span id="errorMessageLabel"></span>
<hr />
<button type="button" id="okButton">OK</button>
</ErrorTemplate>
</atlas:ScriptManager>
<atlas:TimerControl ID="TimerControl1" Interval="2000" runat="server" OnTick="TimerControl1_Tick" />
<atlas:UpdatePanel ID="UpdatePanel1" runat="server" Mode="Conditional" >
<ContentTemplate>
<asp:AdRotator ID="AdRotator1" runat="server" AdvertisementFile="~/Reklam2.xml" />
</ContentTemplate>

<Triggers>
<atlas:ControlEventTrigger ControlID="TimerControl1" EventName="Tick" />
</Triggers>
</atlas:UpdatePanel
timer tick event

protected void TimerControl1_Tick(object sender, EventArgs e)
{
UpdatePanel1.Update();
}

what is the wrong , I can not find the problem.
waiting for your reply...

Hello,

Is there anybody who can help me about this problem?


help,where is the error?
Hello,I solved the problem.

My aspx page

<form id="form1" runat="server">
<atlas:ScriptManager ID="ScriptManager1" runat="server" EnablePartialRendering="True" />
<br />
<atlas:TimerControl ID="TimerControl1" runat="server" Interval="2000">
</atlas:TimerControl>
<br />
<div>
<atlas:UpdatePanel ID="UpdatePanel1" runat="server">
<ContentTemplate>
<asp:AdRotator ID="AdRotator1" runat="server" AdvertisementFile="~/Reklam.xml" />
</ContentTemplate>
<Triggers>
<atlas:ControlEventTrigger ControlID="AdRotator1" EventName="AdCreated" />
</Triggers>
</atlas:UpdatePanel>
</div>
</form
I added a trigger.
<Triggers>
<atlas:ControlEventTrigger ControlID="AdRotator1" EventName="AdCreated" />
</Triggers>
Help of this trigger,when a new advertisement is taken,updatepanel is updating. So without refreshing advertisements are shown on the web site. Reklam.xml is similar to ads.xml, only the name is Turkish.


Thanks for your example, i follow your example to solved my problem:)
not matter