I have a user control with this OutputCache:
<%# OutputCache Duration="86400" VaryByControl="LnkBtnTopVanzari" %>
Where VaryByControl is the id of a link button i use to switch the active view of a multiView contained in an updatePanel.
The problem is that when i press that link button, the page does a full post back and the view is not switched.
If i remove the outputCache directive, all works great (pressing the link button the correct view is shown via ajax).
Do you know where i am wrong?
Thanks.
The VaryByControl parameter is used to vary depending on the value of the control which you specify. As the value of the link button will always be the same, the cache is not varied.
I believe this is intended to be used for controls such as dropdown lists, where it is feasible for the output to be different based on the selected value in the list.
You may want to try using VaryByParam and changing your link button to a hyperlink, specifying the view as a query parameter, or trying out VaryByCustom. Otherwise possibly you could possibly split the content of your views into separate user controls which are themselves output cached, leaving the multiview and your link button outside any caching.
Related
Currently on my website when a user logs in if their role in their row within the Users table is equal to 0 it will give the user 3 options on options.aspx, however if not it will take them to home.aspx
Now I am trying to just do this on one whole page, so if the user was to be directed to the options page, instead it would take them to the home page where the user would have to click an option amongst the 3, if the user has already selected an option then it would load a different content placeholder.
Is a content placeholder what I need to achieve my idea? If so, wouldn't it be abit too easy to get out of the situation since the client could inspect element and edit the visibility on their side?
When you set the Visible="false" property on a server-side control (runat="server") the tag is NOT rendered to the browser. As a result, the client cannot set it as visible. So for example:
<asp:PlaceHolder runat="server" Visible="false">SomeText</asp:PlaceHolder>
The SomeText will be nowhere to be found in the HTML if the user does View Source. If, however, you do a CSS style on a control such as style="display:none" then your concern is 100% valid as the user could just show this.
This same logic hold true for any ASP.NET server-side control. If you set Visible="false" it's never sent to the browser.
Hello Everyone I am a newbie in asp.net,
I have a checkbox inside a repeater which is inside an update panel,the page flickers whenever I click the checkbox, finally found that adding the ClientIDMode="AutoID" controls the flicker and everything works fine.
I am wondering about ClientIDMode what this has to do with the flicker,
went through msdn and found it generate the value of the ClientID property.
First distict the asp.net controls, from the final rendered html controls.
When you make asp.net controls you give them an ID, with this id you can address them and make change on them on code behind and with programming in general.
For example with this code
<asp:CheckBox id="check1" Text="option a" runat="server" />
you can use the check1 to get their value, change the text, and many others.
Now, asp.net must render this check box on the html page. When you make any control on an html page you must set to him a unique ID and name, and heres come the automatic id assignment.
asp.net take care to avoid conficts between final rendered controls and make automatic ids base on the structure that you have use on asp.net side.
For example, if this control is inside a custom control, and this control is inside a master page, asp.net will add also this names on the final id, to avoid conflicts.
Conflicts can exist for example on a repeated control, where you render the same control many times, so there you need to change each rendered id.
Conflicts can exist when you use many times the same user control.
Conflicts can exist when you use the same id on different user controls on the same page.
All that and many others asp.net comes and solve with the automatic generated id on client side render.
Yes, it does have something to do with the flicker.
See this related question for another example of the fact that Repeaters don't handle client ids well, causing exactly this problem because they end up doing a full postback instead of a partial postback.
Setting ClientIDMode="AutoID" is the workaround and allows the Repeater to succeed in doing the partial postack it is supposed to be doing from within the UpdatePanel.
Because of this Repeater bug, without ClientIDMode="AutoID" you were experiencing a full postback and full page load. A full page load does cause a flicker compared to a partial page load.
I have 7 dropdown lists within my page , following a post back from dropdown list 1 I want this to still be highlighted when the page reloads so that I have the ability to tab to the next dropdown list
I have tried smart navigation but this did not work. I'm using framework 3
Any guidance would be appreciated
Thanks
You can use the focus() method
For example in code-behind:
DropDownList1.Focus();
This will give focus to DropDownList1
Alternatively you can use
Page.SetFocus("IdOfControl");
You will need to store the ID of the control in either a session or querystring so you can access it after postback so you know which control to give focus to.
I've three images. I use javascript to mark which one is selected. After user clicks on one I change its class to active. its <li><a>. Now when I wasn't using updatepanel after form post I could see from code behind which element is active and it was correct. After adding updatePanel which contains entire form after postback which should refresh content of updatePanel value is wrong and active is always set to default first <a>. Whats more in this updatePanel there is UploadFile control which doesn't work well because it always has HasFile value to false even though I choose file.
Thanks You for any hints
Your form must be a full postback. You have to add a Trigger for the Full postback, if your FileUpload control is in the update panel.
Alternatively if you want to upload Asynchronously , you could try AJAX AsyncFileUpload control
http://asp.net-informations.com/ajax/ajax-AsyncFileUpload.htm
This is a well known problem, please take a look into the following article:
http://geekswithblogs.net/ranganh/archive/2008/04/01/file-upload-in-updatepanel-asp.net-ajax.aspx
Greetings,
I created a aspx page that uses a master page. Inside I have a control, let's say txtName and I have a submit button, that when I press it it will submit the text in the txtName to another page.
The problem is that the Request.Form key does not have the txtName, instead it something like clt00$Container0&txtName.
Isn't there a way to easily find the key that I want to retrieve from there?
You can implement the behaviour via Cross Page Postback. Then you can access the value via PreviousPage.FindControl("txtName") or via a custom property (see section "Using Property to expose and Consume values of TextBox" in the linked article above)
Make sure they r with in the same form when, it
renders onthe client. If not u will not get on server
look view source n see where u master page control
is