Showing posts with label page. Show all posts
Showing posts with label page. Show all posts

Wednesday, March 28, 2012

Postback issue

In my page, there are a lots of toolkit controls and gridvidw. Sometime when I postpack partially inside a UpdatePanel, I got the following message in a popup message box:

Invaid postback or callback argument. Event validation is enabled using <pages enableEventValidation="true"/> in configuration or <% Page EnableEventValidation="true" %> in page. For security purposes,this fuature verifies that arguments to postbalc or callback events originate from the server control that orginally rendered them. If the data is valid and expected, use the ClientScriptManager.RegiterForEventValidation method in order to register the postback or callback data for validation.

For example, in gridview with paging, when I click on page numnber, sometimes the above message will come out. It comes out randomly. If I refresh the page, it will fix this issue.

How to solve this issue?

The pics you posted are not visible.

A potentially dangerous Request.Form value was detected from the client (ctl00$ctl00$ctl00$ctlToAdd1$ctl00$ctlHeaderFooter$ctl00$txtPageHeader="<p>DO NOT ATTEMPT TH...").

Description: Request Validation has detected a potentially dangerous client input value, and processing of the request has been aborted. This value may indicate an attempt to compromise the security of your application, such as a cross-site scripting attack. You can disable request validation by setting validateRequest=false in the Page directive or in the configuration section. However, it is strongly recommended that your application explicitly check all inputs in this case.

Exception Details:System.Web.HttpRequestValidationException: A potentially dangerous Request.Form value was detected from the client (ctl00$ctl00$ctl00$ctlToAdd1$ctl00$ctlHeaderFooter$ctl00$txtPageHeader="<p>DO NOT ATTEMPT TH...").

Source Error:

[No relevant source lines]


Source File:c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\siteseasytest\b32181f7\172c3a32\App_Web_yzjzpobg.2.cs Line:0

Stack Trace:

[HttpRequestValidationException (0x80004005): A potentially dangerous Request.Form value was detected from the client (ctl00$ctl00$ctl00$ctlToAdd1$ctl00$ctlHeaderFooter$ctl00$txtPageHeader="<p>DO NOT ATTEMPT TH...").]

System.Web.HttpRequest.ValidateString(String s, String valueName, String collectionName) +3219550

System.Web.HttpRequest.ValidateNameValueCollection(NameValueCollection nvc, String collectionName) +108

System.Web.HttpRequest.get_Form() +119

System.Web.HttpRequest.get_HasForm() +57

System.Web.UI.Page.GetCollectionBasedOnMethod(Boolean dontReturnNull) +2025201

System.Web.UI.Page.DeterminePostBackMode() +60

System.Web.UI.Page.ProcessRequestMain(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +6953

System.Web.UI.Page.ProcessRequest(Boolean includeStagesBeforeAsyncPoint, Boolean includeStagesAfterAsyncPoint) +154

System.Web.UI.Page.ProcessRequest() +86

System.Web.UI.Page.ProcessRequestWithNoAssert(HttpContext context) +18

System.Web.UI.Page.ProcessRequest(HttpContext context) +49

ASP.communitydefault_aspx.ProcessRequest(HttpContext context) in c:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\siteseasytest\b32181f7\172c3a32\App_Web_yzjzpobg.2.cs:0

System.Web.CallHandlerExecutionStep.System.Web.HttpApplication.IExecutionStep.Execute() +154

System.Web.HttpApplication.ExecuteStep(IExecutionStep step, Boolean& completedSynchronously) +64


Jason, If you are using code behind to control what gets added to a PlaceHolder for instance...

In ATLAS - we simply issued the

UpdatePanelModal.Update();

Because viewstate would get mucked up. (Article on my blog about this)

In Beta - I find that anytime you issue that command - it causes the error ... I think when mode is conditional - it works but not sure - as I am being forced to use always due to databound controls dissapearing on a modal popup and have not heard any feedback on the issue...

If you are not using code behind to handle - can you post a simple code example that demonstrates the issue?


Jason, I have written down the message text in message box. Forget the pic.


jodywbcb, what's your post for my question?

Postback Multitask progress bar (ajax)

hello

I have a asp.net page that takes several actions uppon a button click.

Suppose this page triggers 3 functions on that button click: (THIS IS JUST AN EXAMPLE)
1) Saves data to local data base
2) Export data do internet data base
3) send emails to 50 users reporting this update

What I want to do is show the user wich action the server is performing at the moment.
basically, it should show (on a Modal PopUP, i figure) all the 3 steps taken.
1) ...saving data...
2) ...exporting data ...
3) ... notifying users ...

does anyone have a solution for this?

thanks

Checkout this threadhttp://forums.asp.net/t/1133013.aspx

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

i have asp.net web page,on page load i create a simple html table with fixed no of rows and no of columns and their names are determined dynamically.now i have few javascipt functions for adding a row to table,for adding another column to table and for removinga row from table.

also i have a asp:button on click of which a xml file is generated from the data filled in by user in the table.but as soon as i hit the asp button to generate xml all newley added rows and columns are deleated.Is it possible to call a server side function without posting the page back.

Yes, it is

take a look at this article about client scripts callbacks:

http://msdn.microsoft.com/msdnmag/issues/04/08/CuttingEdge/

Cheers,

Yani


hey went throught the article actually i mean new to all this so didnt get it completely some code help from ur side will be appriciated

actually i have a method on server side that accepts the html table parses it and writes the data of html table in a xml file.

and i want to call this method on click of a button and without postback.

thanx in advance

sandeep


Sorry man,

I haven't put the client scripts callbacks into practice yet too.

I was going to use them to create a dynamic progress bar, but then i've decided to use the ajax update panel.

It was much faster and cheaper.

Cheers,

Yani

PostBack Problem, Need Help.

I have a page with a drop down that drives a gridview. Now whatever is selected the drop down will drive whats shown in the gridview. The page loads fine and the default value in the drop down loads the gridview fine. Now on each row in the gridview I have an edit button to edit that row. I use a modal popup to edit that row and save it. The modal works great and updates a row. Here is where the problem happens, if I change the drop down to a different value the gridview updates, I edit the row and the modal pop is ok and saves...but without changing the drop down again if I try to edit another row I get this error...

--------
Windows Internet Explorer
--------
Invalid postback or callback argument. Event validation is enabled using <pages enableEventValidation="true"/> in configuration or <%@dotnet.itags.org. Page EnableEventValidation="true" %> in a page. For security purposes, this feature verifies that arguments to postback or callback events originate from the server control that originally rendered them. If the data is valid and expected, use the ClientScriptManager.RegisterForEventValidation method in order to register the postback or callback data for validation.
--------
OK
--------

Now I have tried adding that attrbute to the page tag and it still does not work...it gives me a similar error than the above one. I assume it has something to do with having all these postbacks and the modal is causing one while so is the edit button and they are conflicting somehow...anyway, any direction or solution would great. Let me know if anyone needs to see some code.

Hi Horizon,

In your modal popup, do you make partial or full postback when you update the datagrid row?

If you make partial postback, there is chance the server does not know all about this partial update, especially if you modify or update portions of your page, so by the next time you try to issue partial postback the server will complain about invalid postback event arguments.

It works if you change the dropdown because the dropdown issues full postback so the server now knows about all modifications on your page.

Is it an option to issue a full postback when you update the rows in the datagrid?

If your application does not require high grades of security, you could turn off the enableEventValidation attribute globally for your application (in web.config file).

Probably some ASPX and code-behind code would be helpful here to see how exactly you do the postbacks and updates on your page...

Kind regards,

sbogus.


Thanks you lead me on the right path, I added this to the load event...

ScriptManager.GetCurrent(Page).RegisterPostBackControl(btnSaveRankings);

What this does is cause a full post back on the page now when I click btnSaveRankings which is in my modal panel. Though know its not saving state on my drop down...it reverts it back to the value as if you just came into the site...I am going to post my aspx and aspx.cs file...

<%@. Page Language="C#" AutoEventWireup="true" CodeBehind="index.aspx.cs" Inherits="PowerRankingsAjax.admin.index" %><%@. Register Assembly="AjaxControlToolkit" Namespace="AjaxControlToolkit" TagPrefix="ajaxControlToolkit" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" ><head runat="server"> <title>Add/Edit Power Rankings</title> <link href="../ModalDialogs.css" rel="stylesheet" type="text/css" /></head><body> <form id="form1" runat="server"> <div> <asp:Label ID="lblError" runat="server" Text=""></asp:Label> <ajaxControlToolkit:ToolkitScriptManager ID="ToolkitScriptManager1" runat="server"></ajaxControlToolkit:ToolkitScriptManager> Edit Past Issues <br /> Select Issue: <asp:DropDownList ID="ddlIssue" runat="server" AutoPostBack="true" OnSelectedIndexChanged="ddlIssue_SelectedIndexChanged"></asp:DropDownList> <br /> <asp:UpdatePanel ID="uEditPanel" runat="server" ChildrenAsTriggers="False" UpdateMode="Conditional"> <ContentTemplate> <asp:GridView ID="EditPowerRankings" runat="server" AutoGenerateColumns="false" OnRowCreated="EditPowerRankings_OnRowCreated" > <Columns><asp:TemplateField ShowHeader="False"><ItemTemplate> <asp:Button ID="btnEdit" runat="server" Text="Edit" OnClick="btnEdit_Click" CausesValidation="false" /></ItemTemplate></asp:TemplateField><asp:BoundField DataField="pid" /><asp:BoundField DataField="teamabbr" /><asp:BoundField DataField="team" HeaderText="Team" SortExpression="team" /><asp:BoundField DataField="rank" HeaderText="Rank" SortExpression="rank" /><asp:BoundField DataField="comment" HeaderText="Comment" SortExpression="comment" /></Columns> </asp:GridView><!--cheesy button for the modal popups target control--> <asp:Button ID="btnHiddenRankings" runat="server" style="display: none" /> <ajaxControlToolkit:ModalPopupExtender ID="mpeRankings" runat="server" TargetControlID="btnHiddenRankings" PopupControlID="pnlRankings" CancelControlID="btnCancelRankings" BackgroundCssClass="modalBackground" Drag="true" > </ajaxControlToolkit:ModalPopupExtender> <asp:Panel ID="pnlRankings" runat="server" CssClass="modalBox" Style="display: none;" Width="500px"><asp:Panel ID="RankingsCaption" runat="server" CssClass="caption" Style="margin-bottom: 10px;">Edit Rankings</asp:Panel> <asp:HiddenField ID="hidRankEditIndex" runat="server" Value="-1" /><div class="divCol"></div><div class="divColLast"> <asp:Image ID="imgTeam" runat="server" />  <asp:Label ID="lblTeamName" runat="server" Text=""></asp:Label></div><div class="clearer"></div><div class="divCol">Rank:</div><div class="divColLast">   <asp:DropDownList ID="ddlEditRank" runat="server"> <asp:ListItem>1</asp:ListItem> <asp:ListItem>2</asp:ListItem> <asp:ListItem>3</asp:ListItem> <asp:ListItem>4</asp:ListItem> <asp:ListItem>5</asp:ListItem> <asp:ListItem>6</asp:ListItem> <asp:ListItem>7</asp:ListItem> <asp:ListItem>8</asp:ListItem> <asp:ListItem>9</asp:ListItem> <asp:ListItem>10</asp:ListItem> <asp:ListItem>11</asp:ListItem> <asp:ListItem>12</asp:ListItem> <asp:ListItem>13</asp:ListItem> <asp:ListItem>14</asp:ListItem> <asp:ListItem>15</asp:ListItem> <asp:ListItem>16</asp:ListItem> <asp:ListItem>17</asp:ListItem> <asp:ListItem>18</asp:ListItem> <asp:ListItem>19</asp:ListItem> <asp:ListItem>20</asp:ListItem> <asp:ListItem>21</asp:ListItem> <asp:ListItem>22</asp:ListItem> <asp:ListItem>23</asp:ListItem> <asp:ListItem>24</asp:ListItem> <asp:ListItem>25</asp:ListItem> <asp:ListItem>26</asp:ListItem> <asp:ListItem>27</asp:ListItem> <asp:ListItem>28</asp:ListItem> <asp:ListItem>29</asp:ListItem> <asp:ListItem>30</asp:ListItem> </asp:DropDownList></div><div class="clearer"></div><div class="divCol">Comments:</div><div class="divColLast"> <asp:TextBox ID="txtComment" runat="server" TextMode="MultiLine" MaxLength="500" Width="480" Height="200"></asp:TextBox></div><div class="clearer"></div><div style="white-space: nowrap; text-align: center;"> <asp:Button ID="btnSaveRankings" runat="server" Text="Save" OnClick="btnSaveRankings_Click" CausesValidation="true" /> <asp:Button ID="btnCancelRankings" runat="server" Text="Cancel" CausesValidation="false" OnClick="btnCancelRankings_Click" /></div></asp:Panel> </ContentTemplate> <Triggers> <asp:AsyncPostBackTrigger ControlID="ddlIssue" EventName="SelectedIndexChanged" /> </Triggers> </asp:UpdatePanel> </div> </form></body></html>

cs file...

using System;using System.Data;using System.Configuration;using System.Collections;using System.Web;using System.Web.Security;using System.Web.UI;using System.Web.UI.WebControls;using System.Web.UI.WebControls.WebParts;using System.Web.UI.HtmlControls;namespace PowerRankingsAjax.admin{public partialclass index : System.Web.UI.Page { powerrankings oPowerrankings =new powerrankings(); DataSet ds =new DataSet();public String strWeek;public int intCountVal;protected void Page_Load(object sender, EventArgs e) { ScriptManager.GetCurrent(Page).RegisterPostBackControl(btnSaveRankings);if (oPowerrankings.ConnectToDatabase(lblError) ==true) {if (!Page.IsPostBack) {//GetWeek GetWeek(); BuildEditList(); BuildEditGrid(strWeek); } } ds.Dispose(); }protected void GetWeek() {//Current Week strWeek = oPowerrankings.GetMaxWeek(ds, lblError); }protected void BuildEditList() { ddlIssue.DataSource = ds.Tables[oPowerrankings.GetAllWeeks(ds, lblError).ToString()]; ddlIssue.DataTextField ="week"; ddlIssue.DataValueField ="week"; ddlIssue.DataBind(); intCountVal = oPowerrankings.GetHolder(ds, lblError);if(intCountVal > 0) { ListItem li =new ListItem("Edit","edit"); ddlIssue.Items.Add(li); }else { ListItem li =new ListItem("New","new"); ddlIssue.Items.Add(li); } lblError.Text = intCountVal.ToString();//ddlIssue.SelectedValue = strWeek; }protected void BuildEditGrid(string strWeek) { EditPowerRankings.DataSource = ds.Tables[oPowerrankings.GetEditPowerRankings(strWeek, ds, lblError).ToString()]; EditPowerRankings.DataBind(); }protected void ddlIssue_SelectedIndexChanged(object sender, EventArgs e) { strWeek = ddlIssue.SelectedValue;if (oPowerrankings.isNumeric(strWeek, System.Globalization.NumberStyles.Integer)) { BuildEditGrid(strWeek); }else { } }protected void EditPowerRankings_OnRowCreated(object sender, GridViewRowEventArgs e) { e.Row.Cells[1].Visible =false; e.Row.Cells[2].Visible =false; }protected void btnSaveRankings_Click(object sender, EventArgs e) { oPowerrankings.UpdatePowerRankings(Convert.ToInt16(hidRankEditIndex.Value), Convert.ToInt16(ddlEditRank.SelectedValue), txtComment.Text, lblError); mpeRankings.Hide(); strWeek = ddlIssue.SelectedValue; BuildEditList(); BuildEditGrid(strWeek); uEditPanel.Update(); }protected void btnCancelRankings_Click(object sender, EventArgs e) { mpeRankings.Hide(); }protected void btnEdit_Click(object sender, EventArgs e) { Button btnEdit = senderas Button; GridViewRow row = (GridViewRow)btnEdit.NamingContainer; hidRankEditIndex.Value = row.Cells[1].Text; imgTeam.ImageUrl ="../images/" + row.Cells[2].Text +".gif"; lblTeamName.Text = row.Cells[3].Text; ddlEditRank.SelectedValue = row.Cells[4].Text; txtComment.Text = row.Cells[5].Text; uEditPanel.Update(); mpeRankings.Show(); } }}

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 with MasterPage

hi all

i want to load other page with masterpage without postback

any one cane help me?

AOJ

Hi,

In my opinion, there is not elegant way to achieve this.

First of all, please note that MasterPage is quite different from a container (e.g.: frameset/iframe) in the client side's point of view. The client isn't aware of the existance of masterPage at all. Every actions fired by controls in the masterPage is the same as the one fired by control in a normal page.

So, if you'd like to implement this, what you need to do is to place a UpdatePanel on the masterPage, and load different controls into it programmatically. Then update the UpdatePanel.

PostBack without page refreshing

Hi, guys!

I have a very important question for me.

Does anyone know how to PostBack without page refreshing?

The situation is as following:

There are 2 DropDownLists on my page,

when I select any item from DropDownList1,

DropDownList2 must fill with items from SQLServer without any refreshing of page,

as if it works on desktop application.

Is it possible?

Thanks!

Hi,

check out theCascadingDropDown in the Toolkit.

Grz, Kris.


Hi,

you can put each of ddl into one UpdatePanel with AutoPostBack="true", then you have the postback of only the part of the page included in UpdatePanel.

Bye!
Stefano

Postbacks not working

OK so this is REALLY weird.

My atlas post backs don't work when the page fist loads, but once I refresh the page everything works great. I've compared the source for webpage when it works and when it doesn't and they are identical.

Anyone have any ideas?

Hi,

could you show us the relevant code?

Please see the following post for the code:

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


hello again.

as i said, i've loaded the page and it is working here with or without partial rendering. hum...have you tried building a new web site by using the atlas template?


When I build a new web site useing the atlas template I get the same issue (Atlas only works on reload)

Sample Atlas projects I've downloaded (AtlasControlToolkit) seems to work fine.


hello again.

there's some weird stuff!!! btw, have you used fiddler to see what's happening during a partial postback?


Yes, fiddler isn't getting anything.

Posting On Ajax Help Required.

Hi All,

My requirement is like displaying random advertisements in masterpage. I had a page with Ajax Timer control which on Timer_Tick event fetches me a new image and bind to <asp:hyperlink>, my problem is on page_load also i want to display image, but image is displayed only on Timer_Tick after some fixed 3000 seconds is elapsed. On page_load i want to display same images, my images are dynamic comes from database, i store them in a dataset, and binds to asp:hyperlink on timer_tick. Can anyone help, on how to display image on page_load, is there any way how i can attach the server side event (Timer_Tick) on page_load also, so that it will fetch me the image.

Thanks In Advance,

Karthikeyan.

Consider using the AdRotator control.

The AdRotator control selects and displays an ad randomly each time a page is refreshed.

The AdRotator control in ASP.NET 2.0 populates its image and navigation properties in 3 different ways -
Database, XML and also programmatically.

Check these links for more info & code samples -
http://www.ipona.com/samples/0321257278/11/AdRotator-Bound.aspx
http://www.ipona.com/samples/0321257278/SourceViewer/SrcView.aspx?file=/samples/0321257278/11/AdRotator-Bound.aspx
http://www.c-sharpcorner.com/UploadFile/mahesh/adrotator06142007110621AM/adrotator.aspx
http://blogs.msdn.com/acoat/archive/2005/11/07/AdRotator-Dynamic-Image-Generation.aspx


Thanks for your valuable suggestion, but my requirement is i don't want to do a postback for whole page, just for banner, what i want is to do a Asynchronous postback on fixed timer interval and change banner. First time when the page load there is no banner getting displayed. This is my problem, is there any way through which i can again call Timer_Tick event in page_load so that for the first time a image will be loaded.

Thanks & Regards,

karthikeyan.

PRB: Master Pages and Update Panels/Script Manager - AJAX Magic not working

I have a master page that has the script manager control and a content place holder

I have a content page that is using the above master page and with a gridview control wrapped in an update panel

When the content page doesn't use master pages and the script manager is placed within the content page along with the panel, everything works fine

The problem arises when the master page has the script manager and thhe content page just has the update panel with the gid view. It seems to be doing a regular postback and the ajax plumbing doesn't seemto have any effect..

I also tried adding a page initi handler and specifying the trigger in the code behind but with no luck..

generated page source with script manager in master page is listed below. Why does gettting a common master page scnario be so difficult to getv it working..Please point me in the right direction

<script type="text/javascript">
//<![CDATA[
Sys.WebForms.PageRequestManager._initialize('_ctl0:ScriptManager1', document.getElementById('aspnetForm'));
Sys.WebForms.PageRequestManager.getInstance()._updateControls(['t_ctl0:ContentPlaceHolder1:panel1'], [], [], 90);

//]]>
</script>


Genertated source when the script managersits on the page and the content page does not use any master pages

<script <script type="text/javascript">
//<![CDATA[
Sys.WebForms.PageRequestManager._initialize('ScriptManager1', document.getElementById('aspnetForm'));
Sys.WebForms.PageRequestManager.getInstance()._updateControls(['tpanel1'], [], [], 90);

//]]>
</script>

Hi Ajaxnewbie,

Could you please post your code, so we can see how you have implemented it. Thanks

Regards,


Good question... I have exactly the same problem. I wish there would be a valid answer for this post.

thanks!

Pre load

Hi,

I would like make a pre load during load my page.

How calculate the time of load ?

Hi Michel,

Can you please give some more details on what exactly you're trying to do?

Thanks,

Eilon


It's ok, I found it.

<atlas:UpdateProgressrunat="server"ID="UpdateProgress1"><ProgressTemplate><br/><br/><br/><imgsrc="Images/indicator.gif"alt=""/><br/>Loading...</ProgressTemplate></atlas:UpdateProgress>

Monday, March 26, 2012

Preventing an UpdatePanel rendering after a Postback

Hi Everyone,

I have a page with three UpdatePanels, let's call them A, B and C and I have a control in B (a webgrid from ComponentArt) which issues a postback when one of it's rows is selected. What I would like to happen is for that event to be processed on the server, however I only want C to update its display (because in B, that row in the grid automatically changes it's appearance, so there is no need for the grid to be redrawn). Do you know if this is possible, ie to switch off the normally-useful behaviour of Atlas always refreshing the UpdatePanel containing the control that triggered the postback.

Thanks for any helpSmile [:)]

Rob.

Try insert Mode=Conditional in the Properties of UpdatePanel.

Bye.


Thanks for replying Paulo, however the mode is already set to "Conditional" for all of the UpdatePanels.


Sorry, but I don't think it's really possible.

You can cause 'C' to update by calling the Update method on that UpdatePanel in code behind, but if 'B' is causing the postback due to an event firing within it, 'B' is going to either force a full postback if its not in an UpdatePanel or a partial postback if its contained within an UpdatePanel.

The only idea I have is to change from the postback occurring on a row selected to a JavaScript command or something like tied to the onclick event to change the appearance of the row and then click a hidden button through JavaScript or something like that to cause 'C' to postback.

A partial postback is a lot like a regular postback and there's a difference in the parameter of the Render methods that determines what Html is sent back down to the browser.(Check out my blog posting on the subject.)

- Joel

I think this could be helpful (http://forums.asp.net/thread/1266249.aspx). I don't know if it's really what are you looking for but try it. I had a similar problem. I wanted to update panel B when I click on control in update panel A. The solution described in the thread works (and is very simple).

Pavel

Previous rows display when a new row add in GridView (in UpdatePanel) after hitting enter

I am having a problem in GridView using UpdatePanel. I have UpdatePanel which contains a GridView. When I enter rows in GridView and refresh a page it remove rows from Grid and if I enter again it shows only new entered row, works fine.

But when I enter few rows in Grid then click on address bar hit enter on it, it removes the rows from Grid and when I again enter a row again then it shows new with previous rows.

Can anybody tell me where am I doing a mistake.

Thanks in advance.

It works fine in debug mode but when I deploy the application on server, it shows previous records with new record.

Any idea?

Thanks in advance.

Previous ViewState being used after UpdatePanel refresh

I am not sure its a problem with a viewstate--just a guess. The problem is this:

I have a page that uses a master page. It has two updatepanels in it. One updatepanel has a dropdownlist and one has a button and a label. When the button triggers a partial postback, I set the value of the label and can see it change on the page. When the dropdownlist triggers a partial postback the label switches back to its previous value right before the partial postback. When I inspect the value in the code behind for the dropdownlist the previous value is what is in the label.

What could be causing this? Has someone else had a similar problem? Where was the previous value even stored for it to be retrieved. Does each updatepanel have a viewstate?

Due to the complexity of my master page, I cannot put the dropdownlist, button and label in the same updatepanel. Is that the source of the problem?


There's one ViewState for the entire page, and it's updated during each async postback.

Could you boil this down to a small sample (e.g. a couple UpdatePanels, one with a DropDownList, one with a Label) and paste the code here?

Also, try removing the UpdatePanels (or setting EnablePartialRendering="false" on your ScriptManager) to see if this works with regular postbacks. That may help to figure out what's going wrong.


Also make sure each UpdatePanel's UpdateMode is set to conditional.

Printing TabContainer

Hi there!

Just wondering if anyone has managed to achieve the following:

I've got a page with a TabContainer in it... and I want to print it. By default the printed page will show the tab container just as it appears on screen.
But that's not what I want!!
I want to the printed page to reflect the contents of the TabContainer e.g.

Tab1

Tab1's contents get rendered

Tab2

Tab2's contents get rendered

etc. etc.

I've had a brief look at how to accomplish this, but am realising this is probably going to take a fair bit of time and effort to do. So I was wondering if anyone had "done the work for me" and I could crib a solution together!!!

Now I suppose you want to know why I want to do this... well basically I'm going to have 100's of pages containing tabs that my users can view. Despite the information being available on screen they love to print anything and everything off for their own records. I really don't want to end up 2 versions of every page... 1 for on screen display... and one made nice and pretty for printing purposes!!

My current thoughts are:

    Write an extender to hook into the beforeprint and afterprint events on the client to "pretty" everything up.

    Write some @dotnet.itags.org.media print and @dotnet.itags.org.media screen to maybe deal with the changes

    Probably my favourite option... write a control adapter for the TabContainer... this could look at a querystring parameter to determine if I am trying to render a printable version or not. If not, render as normal, otherwise change the output so that each TabPanel is visible and lined up vertically one after the other.

Any ideas/thoughts??

Cheers,

James

Hmmm... been thinking about this a fair bit more since I posted... I'm now convinced that the ControlAdapter route is the best.

I'm playing round with a solution that seems to work quite well (and thankfully took a lot less time than I originally anticipated).
Still got a few things to sort out though to make it look "right"!


[Ignore]


[Sorry ignore again]

PRM_ParseErrorDetails null or not an object.

I'm getting the following javascript error in my page whenver i try to use an UpdatePanel:

"Sys.WebForms.Res.PRM_ParseErrorDetails is null or not an object."

I have the RC1 dll in my bin folder, all the relevant entries in my web.config, and this worked fine before, but suddenly it's gone kaput!

Any help would be great.

Can you repro this error again? Try to post some codes?to?repro?this?error here.
Try to debug javascript error according to the following steps.
Steps:
1.Create a file based web site
2.Add a JavaScript file called MyScript.js to the root of the project
In this file, add the following:
function MyCustomFunction()
{
//doing custom work
alert("MyCustomFunction ran!!!");
}
if (typeof('Sys') !== 'undefined') Sys.Application.notifyScriptLoaded();
3.Add an ASPX page to the application
4.Add a ScriptManager to the page and add the above script the Scripts collection
<asp:ScriptManager ID="ScriptManager1" runat="server">
<Scripts>
<asp:ScriptReference Path="~/MyScript.js" />
</Scripts>
</asp:ScriptManager>
5.Ensure that the Disable Script Debugging options are unchecked in Internet Explorer's Advanced Properties.
6.Set a breakpoint on the alert("MyCustomFunction ran!!!"); line in the MyScript.js file
7.Ensure that Internet Explorer is configured for debugging using information from this lesson
8.Press F5 to start debugging.
Does the breakpoint get hit?
Which processes does Visual Studio attach to? (hint: check Debug | Attach to Process..)
9.Add the following HTML to the <body> of the ASPX page:
<input type="button" value="Call Function" onclick="MyCustomFunction()" />
10.Press F5 to start debugging.
Does the breakpoint get hit?
Which processes does Visual Studio attach to? (hint: check Debug | Attach to Process..)
11.Add each item listed below after the alert(); in MyCustomFunction() one at a time and Press F5 to debug the page. i.e. Add item "a" from the list, press F5. Remove item a and add item "b" and repeat. Answer the following:
Does the breakpoint get hit?
Which processes does Visual Studio attach to? (hint: check Debug | Attach to Process..)
a.debug.assert(false, "That wasn't supposed to happen!", true);
b.debug.fail("Did I break?");
c.debug._traceDump(Sys.Application, 'object name', true, '... ');
d.debug.trace("Is this a trace or what?");
12.While you're attached to the iexplore.exe process, take a look at the Script Explorer (Debug menu, Windows, Script Explorer).

Wish the above can help you.

probably simple but i am new - Trying to do a partial render on a master page for my navi

I am trying to learn ajax and i got off to a fairly good start but i am stuck on this one and couldnt find any answers on the net.. i understand the use of a script manager and a updatepanel i got it to work on a page with a tree and when you select a item it loads a picture into a imgbox and it works great but here is my problem

I have a master page.. on the master page it contains my navi bar. each of the 4 buttons opens a new content page (*.aspx). I am trying to set it up so the Navi bar doesnt reload everytime i open another content page.. i want just the contentplace holder to refresh.. I have tried putting a updatepanel around my navi bar but it just doesnt seem to work.. i know this is probably really simple and i want to thank everyone in advance.

Thanks

-steve

I think you were on track when u put update panel over your menu. Just make sure that the update panel UpdateMode=Conditional

This way it will only cause postback when some trigger or other method will make it to cause postback.

Here are some good tutorial on UpdatePanel and update methods.

http://www.asp.net/learn/ajax-videos/video-177.aspx <-- this one talks about conditional mode

http://www.asp.net/learn/ajax-videos/video-159.aspx

http://www.asp.net/learn/ajax-videos/video-118.aspx

Also, you can do it other way around and place an Updatepanel in your Content Holder, and set it to update based on the menu selection. This way only parts your need actually be updated in content holder.


hello.

hum, i'm not following: you're opening a new content page but you want to do that without refreshing the page presented in the browser? if that is what you want, then the answer is: cannot be done. you'll have to refactor your site so that the content is loaded through user controls. if that is not what you meant with the previous mail, please give us more information.


Luis Abreu:

hello.

hum, i'm not following: you're opening a new content page but you want to do that without refreshing the page presented in the browser? if that is what you want, then the answer is: cannot be done. you'll have to refactor your site so that the content is loaded through user controls. if that is not what you meant with the previous mail, please give us more information.

Ok.. let me try to explain it better for you..

Files:

Masterpage.master
Home.aspx
contact.aspx
services.aspx
portfolio.aspx

So all of the pages above use Masterpage.master as the master page The master page is layed like this

Top Image
Navi Bar
ContentPlaceHolder
Bottom Image

so lets say we start out at home.aspx and we want to click on the contact img (on the master page) and it goes to contact.aspx
i want to do it in a way that instead of loading contact.aspx and reloading the content of the masterpage.. it only loads the contentplace holder..

I understand what your saying but what controls would i have to use.. or maybe i set up the image the way its linked wrong i used html.. here is the code maybe i should do it another way? Now you have me really thinking.. ill tinker with it more later today but i greatly appreciate your help.. thanks


hello again.

ok, then it's option 1. i think that in this case, you'd need to refactor your site so that it only has one page. you'd need to transform home, contact, services and protofolio pages in asp.net user controls which would be loaded when you click on the menu. I've written an old post that shows how to replace the contents of an updatepanel. it might help you get starting:

http://msmvps.com/blogs/luisabreu/archive/2007/02/15/adding-controls-to-an-updatepanel-through-code.aspx


hey Luis.. ok i started using ascx and everything works fine except for the fact that now when i load a ascx file into a contentplaceholder in a updatepanel the asptreeview that i now have as a webcontrol instead of a page wont work... any ideas? it wont let me expand anything..

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

Probably, I found a bug [NewLine in MultiLine TextBox]

Try to run this sample (enter to textbox some lines of text, and then click "Post"):

<%@dotnet.itags.org. Page Language="vb" AutoEventWireup="false" CodeBehind="WebForm1.aspx.vb" Inherits=".WebForm1" %><!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml" ><head runat="server"> <title>Untitled Page</title></head><body> <form id="form1" runat="server"> <div><asp:ScriptManager ID="ScriptManager1" runat="server"></asp:ScriptManager><asp:UpdatePanel ID="updPanel" ChildrenAsTriggers="true" runat="server"><ContentTemplate><asp:TextBox ID="txtTest" runat="server" TextMode="MultiLine" /><asp:Button ID="butTest" runat="server" Text="Post" /><br /><div style="border:solid 1px red; padding:20px;"><%=txtTest.Text.Replace(Environment.NewLine, "<br/>")%></div></ContentTemplate></asp:UpdatePanel> </div> </form></body></html>

I am using a release version of AST.NET AJAX.

What's the bug?

If you enter some lines of text in Firefox into textbox, and then post it to the server via AJAX, newline symbols will be damaged.

In Opera and IE all works fine.


"Firefox" would be the reason I didn't see the error initially. That is a pretty annoying bug.

I'm experiencing this exact same issue ... did you get it resolved?

Cheers!