State Management :: Set A Default Value To QueryString On Pageload?
Aug 26, 2010I'm using Response.Redirect for empty QueryString.
[Code]....
I'm not sure if this is the best way to do this.
I'm using Response.Redirect for empty QueryString.
[Code]....
I'm not sure if this is the best way to do this.
Here is my scenario.In default.aspx page user selects the country, state, city from drop down list, and store them in cache for further use. but when other user open the web site from other computer it shows the same country, state, and city selected by user 1. Is there any problem related to cache? I have stored data as following.
cache["ctryID"] = ctryID;
cache["stateID"]= stateID;
cache["cityID"]= cityID;
I want to show default country, state , city at page load of default.aspx
[URL]
i want to get url without c=2, i want to get this
[URL]
is it possible?
i want to save the recent state of all controls against a button1 click event. e.g. recently selected item of a dropdownlist should persist selected when user loads page next time, if he/she had clicked button1 before leaing this page. And same for allother controls on this page.
View 1 RepliesIf you do not configure Session State in the Web.config what is the default? I understand it would read the Machine.config, but if that is not configured, then what is the default? In Proc with cookies?
View 1 RepliesI do not know that How to hide the querystring parameter from url in asp.net
View 5 RepliesHow to remove querystring items? Dim currentUrl As String =[URL] Remove the querystring("link") key item and it's value? It will now become [URL]
View 4 Repliestrying to pass a guid value to querystring - it should take the guid value from one page to another. i get an error: value cannot be null, parameter name: g. so my guid value is not being pass to my second page. below is code:
Page one:
static Guid g = Guid.Empty;
public static string userID = g.ToString();
string userName = string.Empty;
[code]...
My app has broken after upgrading to ASP.NET 2.0. The problem is that Request.QueryString is empty when the SelectedIndexChanged event of a IE Web Controls tab strip is fired. It worked perfectly in ASP.NET 1. I have the tab strip contained within my own UserControl.
View 3 RepliesI've a Linkbutton control in the master page. And in the content page(Home.aspx) i'm trying to navigate it an aspx page(Apply.aspx) passing a value using querystring. Everything is working fine when i click the apply linkbutton control for the first time i.e i'm able to get the value the querystring and able to use it.
But when i click on the same linkbutton second time, i'm not getting the querystring value?how to persist the querystring value on reloading?
I have trouble getting hold of the UserName from the QueryString. My data is not displayed on my page.
What is the problem with this code:
[Code]....
I have a aspx page and there is a web user control that must load dynamically with the data related to the aspx page....
ok so I want to use a querystring and pass it to the web user control.....how do I do this?
then also how do I pass a querystring from a web user control back to a aspx page?
This is a question I always had...and therefore never actually started to use the web user control
Which is best option to store confidential information in a page?Control,Session,QueryString etc ... ?And also the performance also should be good ... ?
View 11 RepliesI'm using sessions to track user name. I assign Session["userName"] in my login procedure. The sessionn gets timeout in about 15 minutes. What I need to do is, if the session timeouts I need to redirect the page to the Default.aspx page.
How can I do this? Any code example would be great.
I have a very simple form with just 3 textboxes.
If I wait for more then 20 minutes then I get somthing like this in the URL:
MyApplication/Default.aspx d=%2fxafR%2f74B0PcNn%2f9jV%2fwWWZ2D34N6cCUyYC29EXUhCqaHDbkpGRLbs55f4rYNbnRqr4rJOn5ynQ
I was on the MyApplication/Submit.aspx but after a wait of 30 minutes when I hit the submit button it got redirected to the above page with that long string.
I did not have any session variables in my application. Then why this redirection.
Also I could not find any error log from Application_Error method.
I am developing a new website and I have a very strange problem. Depending on a simple query string parameter value I have "Internet Explorer cannot display the webpage" or a correct page. Let me show a couple of examples:
This url works, and displays the value passed in the "data" parameter:
http://62.22.11.221/default.aspx?data=cppexample
But this url does not work and I don't really know why:
http://62.22.11.221/default.aspx?data=cpp%20example
when we go for client and server side state management in asp.net
View 2 RepliesI am doing a POC of making my website run faster. Currently it stores huge object data in Session while passing information from one page to another. What I was thinking is to use shared methods and properties instead of session. It works, but wanted tocheck if this is an optimum way to do it. Below is the code that does not use session but still pass object data from one page to another:
[code]...
i have a form on page1.aspx with several controls (textbox, dropdownlist, etc).on Page1 PageLoad event i load data from database and performe databinding.From Page1 a user can, by clicking a specific button, move to Page2.aspx to insert some details and, after saving details, he returns to page1.
if save changes are made on control on page1 before save them to db, obviously, these are lost on return from page2 (because are reloaded on pageload from db).How can i save control status between pages round trip?
i need to know the full concepts state manegemnt in asp.net,..in which site i will get the correct concept for state management....
View 4 RepliesUser Interface: 2 Labels; 1 Buttons
Requirements: Create a Web Page in ASPx that will do the following:
1)One label will provide a count of how many times Button 1 has been clicked in the current session.
2)One label will provide a count of how many times Button 1 has been clicked by all users of the application. The Application Code for the Button should start at 100 (set this in the Global.asax file). this is what i have so far but i cant seem to get the application state to work properly.
aspx.vb
Partial Class _Default
Inherits System.Web.UI.Page
Dim clickcount As Integer
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
If Session("ClickCount") Is Nothing Then
clickcount = 0
Else
clickcount = CInt(Session("ClickCount"))
End If
If Not IsPostBack Then
If Request.Cookies("UserName") IsNot Nothing Then
Label1.Text = "Welcome Back " & Request.Cookies("UserName").Value & "."
End If
End If
Dim clickCounta As Integer = CInt(Application("ClickCount"))
End Sub
Protected Sub PostBackSession_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles PostBackSession.Click
clickcount += 1
lblClkCnt.Text = "Current Click Count is " & clickcount
Application.Lock()
Dim clickCounta As Integer = CInt(Application("ClickCount"))
clickCounta += 1
Application("ClickCount") = clickCounta
Application.UnLock()
AppClick.Text = clickCounta
Dim nameCookie As New HttpCookie("UserName", _
TextBox1.Text)
nameCookie.Expires = Now.AddYears(1)
Response.Cookies.Add(nameCookie)
End Sub
Protected Sub PostBackSession_PreRender(ByVal sender As Object, ByVal e As System.EventArgs) Handles PostBackSession.PreRender
Session("ClickCount") = clickcount
Application("ClickCount") = clickcount
End Sub
End Class
global.asax
<script runat="server">
Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs)
Dim clickCounta As Integer = CInt(Application("ClickCount"))
Application.Add("ClickCount", 0)
End Sub
Sub Application_End(ByVal sender As Object, ByVal e As EventArgs)
Dim clickCounta As Integer = CInt(HttpContext.Current.Application("ClickCount"))
End Sub
Sub Application_Error(ByVal sender As Object, ByVal e As EventArgs)
' Code that runs when an unhandled error occurs
End Sub
Sub Session_Start(ByVal sender As Object, ByVal e As EventArgs)
End Sub
Sub Session_End(ByVal sender As Object, ByVal e As EventArgs)
End Sub
Possible Duplicate:
Removing a querystring from url in asp.net
How to hide asp.net querystring displayed in address bar as default.aspx?id=2&name=sanjay
Customer were getting "View State Validation Error" due to worker process recycling at our production webserver and to fix that i applied machinekey and then move my Session state Mode from In Proc to State Server to retain session data and not kick out the customer to relogin. I had serialization issue with one object which has to be stored in session but when i moved it out of session i could able to resolve the issue.
But doing all these i was partly successfull in keeping the user in their session when Worker Process recycle event occurs.I was able to refresh the page or make a post back by clicking the refresh button and also able to retain the session values. But the Problem occurs when sending asynchronous request to server which we do periodically every 15 minutes from the moment the user logs in.The web page doesnot update data on website when sending asynchronous request.By Debugging I found at this particular code point it fails to make a postback which is required.
<%=GetHintFromServer%> (When there is no Worker Process recycle i t gets replaced by
WebForm_DoCallback('__Page',message,ShowHint,null,null,false) on postback) Everything works fine when there is no Worker Process Recyling but when it happens looks like sending request asynchronously using javascript fails .Remember When I make a post back by manually clicking submit button everything works fine.
SendRequest(Asynchronous)
function SendRequest(msg, isBusy, chartMsg, vesselMsg)
{
try
{
//confirm("msg"+msg+"isBusy"+isBusy+"chartMsg"+chartMsg+"VesselMsg"+vesselMsg);
_busy = isBusy;
if(chartMsg != null)
{
//confirm("chartMsg"+chartMsg);
_element.SetMessage(true, chartMsg);
}
if(vesselMsg != null)
{
confirm("chartMsg"+vesselMsg);
_element.ShowVesselLoading(true, vesselMsg);
}
_stuckWatchdog = setTimeout( "ClearPendingRequest();", 60000);
var message = msg;
var context = '';
<%=GetHintFromServer%>
}
catch(e)
{
alert( "Exception error on SendRequest(): " + e);
}
}
Let me explain, describing the scenario:In a custom server control (in my case, derived from CompositeControl), in the overidden CreateChildControls method I create a complex tree of subcontrols, using information from a db.The db provides both information on which controls I need to create (the user interface's structure) and the data used to fill these controls.Than the user can interact with the control and change the data (that becomes different to what stored on db).
My custom control lives in the same page where there are other controls, obviously.And these controls can cause a postback at any time.What I need is that my custom control keeps the data entered by the user across these postback, without reverting to the original data and loose the user data entry.
Here is the first doubt:
1)I create the subcontrols dinamically in the CreateChildControls at any page refresh (both on first call than on postback).I know that the framework solves the reference between the posted data and the controls I create in the CreateChildControls in order to set properties and raise control events, but can you tell me when and how it actually does this? In which phase of page life cycle? What happens after the CreateChildControls?
A second doubt:2)If the user interface structure must change as a consequence of the data entered, I had to execute CreateChildControls twice (the first time to recreate the original interface to get the events and the second time to create the new interface)
In which phase of page/control lifecycle do I have to make the second call to CreateChildControls? I do it on Prerender now, but is it right or wrong, and why?
I am new to .net 4.0 and am using EF Model and SessionState Mode=SqlServer and I am getting this error below:
Unable to serialize the session state. In 'StateServer' and 'SQLServer' mode, ASP.NET will serialize the session state objects, and as a result non-serializable objects or MarshalByRef objects are not permitted. The same restriction applies if similar serialization is done by the custom session state store in 'Custom' mode.
I checked the stack trace and its complaining about
[assembly: global::System.Data.Objects.DataClasses.EdmSchemaAttribute()]
[assembly: global::System.Data.Objects.DataClasses.EdmRelationshipAttribute("PoplarGroveModel", "tblMenuRole", "tblMenu", global::System.Data.Metadata.Edm.RelationshipMultiplicity.Many, typeof(PoplarGroveDataModel.Menu), "tblRole",
[Code].....
I marked it as serializable but then it complains about System.Data.Objects.ObjectContext is not marked as serializable and hence throws the same error.