|
I have a question about using session variables since this is the first C# 2010 web form app that I am running.
Right now I am passing 3 session variables between 2 web pages in the web application that I setup. This is a data entry application where some information is entered on page 1 and the rest of the information is entered on page 2.
When the user has finished entering the information for the first customer. Now the user will be ready to setup information for the second user.
From what I have seen on the internet session variables last up to 20 minutes. Thus I basically do not want the information saved from customer 1 to be entered into the database file for customer 2 by using session variables.
Thus to prevent this from occuring, I am coding the following before the user clicks the button to enter data for the next customer:
Session.Remove("var1");
Session.Remove("var2");
Session.Remove("var3");
Response.Redirect("~/page1.aspx");
Can you tell me if this is the best method for clearing out session variables and/or if there is a better process you would recommend? Can you tell me and/or point me to a reference that will explain your answer to me?
|
|
|
|
|
try to use session timeout.Sometime,network is not well and session has not remove.
|
|
|
|
|
Looking into the above description, i could make 2 things.
1. you have some session variables that you are using for custom logic.
now you want to use session["var1"] for filling customer1 information.
2. you might have some session variables that are required for maintaining user sessions. (probably)
and perhaps with the same user ID you will have to use the same session variables with separate set of data.
Session.Remove("var1"); for all the variables should work once you save the data into database. but in case you dont have the requirement mentioned in #2 point i.e. maintaining user session then instead of clearing the variables one by one you can simply do a session.Abandon too.
in short, if you are not using sessions to track the login status then you can use session.abandon too.
Every now and then say, "What the Elephant." "What the Elephant" gives you freedom. Freedom brings opportunity. Opportunity makes your future.
|
|
|
|
|
I would check to see if the session exist first before removal, so you don't generate a object does not exist error.
[EDIT] wrap code in tags
If Not Sesson("var1") Is Nothing Then
Session.Remove("var1")
End If
|
|
|
|
|
|
I am asking this question since this is the first C#.net 2010 web form application that I am writing. In this application I am using linq to sql to connect to a sql server 2008 r2 database since that is what the rest of the web pages do in this application.
My question is on one particular web form page, I have been creating new datacontexts objects for each button that is used on this web form page. All these data context objects refer to the same .dbml file.
Thus I am wondering if I should use only one data context object and put that creation of the data context object on top of the web page and give it a protected web form page access?
Can you tell me and/or point me to a reference that will tell me what the best way is to handle this situation and show me how to accomplish this task in code?
|
|
|
|
|
sc steinhayse wrote: if I should use only one data context object and put that creation of the data context object on top of the web page and give it a protected web form page access
I would suggest one datacontext but this way: Request scoped DataContext [^]
Also, read about datacontext to understand it's role and what it does, here: MSDN: LINQ to SQL - Datacontext[^]
|
|
|
|
|
In a C# 2010 webform application I am working on a couple of custom validators. One of the validators needs to look at a sql server 2008 r2 database to find the lowest and highest value for a create date field.
My question is how to setup a customer error message that can be generated. Basically I would like the error message to say the create date needs to be within a certain date range. I would do not want to say the create date requested values is not contained in the specific table.
Thus can you tell me how to setup a custom error message that the custom validator can use?
|
|
|
|
|
|
That uses the same concept as if checking to see if a username exist before form submission.
Most people write JavaScript, to capture the value, and submit it to a web service, the web service then sends back the answer, or parameters needed to make a decision, and then the same JavaScript does a comparison, and creates a validation message, or alters the GUI for a clean notification.
concept sample
This is a link on the CJ that clarifies my thoughts into code, with explanations.
|
|
|
|
|
Hi,
We have developed an application using ASP.net 2008 and SQL server 2008. when it runs locally, it works okay but when it is published to a host. It creates following error:
Parser Error
Description: An error occurred during the parsing of a resource required to service this request. Please review the following specific parse error details and modify your source file appropriately.
Parser Error Message: Could not load file or assembly 'Telerik.Web.UI, Version=2010.2.929.40, Culture=neutral, PublicKeyToken=121fae78165ba3d4' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
Source Error:
Line 1: <%@ page title="" language="C#" masterpagefile="~/MasterPages/ProductsCatalog.master" autoeventwireup="true" inherits="ProductsCatalog_Subcategories, App_Web_subcategories.aspx.915388b4" enableviewstatemac="false" theme="Austin4" viewStateEncryptionMode="Never" maintainScrollPositionOnPostBack="true" %>
Line 2: <%@ Register Assembly="Telerik.Web.UI" Namespace="Telerik.Web.UI" TagPrefix="telerik" %>
Line 3: <asp:Content ID="Content1" runat="server" ViewStateMode="Disabled" ContentPlaceHolderID="ContentPlaceHolder2">
Source File: /ProductsCatalog/Subcategories.aspx Line: 1
Assembly Load Trace: The following information can be helpful to determine why the assembly 'Telerik.Web.UI, Version=2010.2.929.40, Culture=neutral, PublicKeyToken=121fae78165ba3d4' could not be loaded.
WRN: Assembly binding logging is turned OFF.
To enable assembly bind failure logging, set the registry value [HKLM\Software\Microsoft\Fusion!EnableLog] (DWORD) to 1.
Note: There is some performance penalty associated with assembly bind failure logging.
To turn this feature off, remove the registry value [HKLM\Software\Microsoft\Fusion!EnableLog].
Version Information: Microsoft .NET Framework Version:4.0.30319; ASP.NET Version:4.0.30319.237
Any comment or suggestion for resolving this error is appreciated.
|
|
|
|
|
Could not load file or assembly 'Telerik.Web.UI, Version=2010.2.929.40, Culture=neutral, PublicKeyToken=121fae78165ba3d4' or one of its dependencies.
You are using Telerik controls in your application. You must have installed Telerik controls on your system such that you can use them in your project locally. Post installation, you have telerik dll's reference in your project that allowed you to use the telerik controls.
When you published it on server, application is looking for telerik assembly (Telerik.Web.UI, Version=2010.2.929.40) to reference the controls used but is missing. Just find the telerik dll on your local system and place it in BIN folder of your web application on server. It should be good to go.
|
|
|
|
|
I need to create an image of a pdf file, so I'm shopping around for something free.
I'm giving the Tall PDF Thumbnail a spin, but making some changes. The documentation shows uploading a pdf file, and grabbing the bytes of the inputstream, writing it to a session key, and then pointing the Tall Object to the session key.
How they do it, via file upload in c#
byte[] buffer = new byte[postedFile.ContentLength];
postedFile.InputStream.Seek( 0, System.IO.SeekOrigin.Begin );
postedFile.InputStream.Read( buffer, 0, postedFile.ContentLength );
string sessionID = Session.SessionID;
Session[sessionID] = buffer;
I want to read it off the disk drive, because it's already there, but in vb
Dim uniqueKey As String = Guid.NewGuid().ToString()
Dim fileStream As FileStream = File.OpenRead(physicalPath)
Dim fileLength As Long = fileStream.Length
Dim buffer() As Byte = New Byte(fileLength) {}
fileStream.Read(buffer, 0, buffer.Length)
Context.Session.Add(uniqueKey, buffer)
In theory, bytes are bytes, regardless of how you get them, so I should be able to create the same data buffer needed to feed the Tall Object, to create a thumbnail, but I'm not able to get the object to do it's thing.
My question is, does my translation look correct, and is my theory valid here, or am I way off base on this?
|
|
|
|
|
So my code was correct, I was missing an empty webform that held the image source.
The image is pretty small though, could use something larger.
If anybody knows of some free code to convert a pdf to a png or jpg, let me know.
|
|
|
|
|
Hello!
My name Makara called Blueshark.
I want to ask you
How should i get Microsoft speech Object Library 5.0 into my vb.net?
|
|
|
|
|
|
In a C# 2010 web form application that I am working on, I am hoping there is a better way for page 1 and page 2 to communicate with each other besides using just session variables. Basically on page 1 there are 'clear and 'next' buttons. The clear button clears the page and the 'next' button updates the database and points the user to page 2.
On page 2, I have the following buttons: back, delete, and submit.
Basically the user enters most of their information on page 1. They hit the 'next' button to continue entering information. If the user wants to change some of the information on page 1 when they are on page 2, the user hits the 'back' button.
Thus my problem is on page 1 for the 'next' button. This button needs to know if the user has hit the 'back' button from page 2. If the user has returned from page 2 to page 1, the user will only update a row in the database. If this is the first time for the user on the database, then, then an insert needs to occur in the database.
The only way I can think of for the two pages to communicte with each other is to use session variables.
If you have any other suggestions, can you tell me what they are?
|
|
|
|
|
|
Hi all,
I have created a user control which has a grid on a Asp:Panel, and a button.
When the user control is placed on a page only the button will be displayed and on the click of this button the panel will be displayed as a popup using ModalPopupExtender.
This page postbacks to itself on another button, during this event the Panel is displayed for a second and then goes off.
How can that be avoided? I don't want the Blank Panel to displayed while page load.
I have already tried setting the panel's visibility in various events of page life cycle to avoid it... but none works.
Any help or direction would be appreciable.
Thanks,
AB
Thanks & Regards,
AB
"Everyone is a genius at least once a year"
|
|
|
|
|
I think the original concept of the extender was to close or hide the panel after a postback is issued.
To keep the panel visible, use the show or hide in your postback code.
modalpopupextender.show()
modalpopuextender.hide()
|
|
|
|
|
I have done the same, but the problem is during page rendering the Panel is rendered for few seconds and then goes off... I don't want the panel to be displayed until the button is clicked.
Thanks & Regards,
Pramod
"Everyone is a genius at least once a year"
|
|
|
|
|
I have the following questions to ask about using session variables in a C# 2010 web form application that I am working on:
1. Do session variables exist on one one web page and/or can you pass the session variables between two web pages in the same web application? Can the session variables be shared between the two web pages? Can you explain your answer?
2. When a user is logged into a data web application that is used to update 2 tables in a sql server 2008 r2 database and uses session variables, do the session variables retain the their values?
Basically a user enters information for customer One and updates the database. Now the user needs to enter information for a different customer that is customer number two. The user returns to the first of a series of web pages to enter the informnation for customer two.
Do the session variables between when data is entered for customer One and the start of customer two retain the same value? If so, can you tell me how to clear out the values for those session variables when the user goes to enter data for the second customer? If not, can you tell me how the session variables get automatically cleared out?
|
|
|
|
|
|
When you assign a session value, the session value is held by the IIS Web Server, during the lifetime of the Session.
In other words, when a user goes to your website, the web server creates a session ID for that user, and creates a timeout, which is usually 20 minutes by default.
During that period in which the session is active, you can assign session values that will last until the timeout period. No matter what page the user is viewing, the values will remain until the timeout, in which they are all destroyed.
Be careful using session values, they do consume server memory, and are susceptible to hacking.
[EDIT]
sc steinhayse wrote: how to clear out the values for those session variables
Session.Add("secureLevel", 5)
Session.Remove("secureLevel")
Session.Abandon()
Session.Clear()
|
|
|
|
|
for (int i = 0; i < dtCurrentTable.Rows.Count; i++)
{
DropDownList ddlFrequency = (DropDownList)mdlpopupGrid.Rows[rowIndex].Cells[4].FindControl("ddlFrequency");
drCurrentRow = dtCurrentTable.NewRow();
dtCurrentTable.Rows[i]["Start_Salary"] = ((TextBox)mdlpopupGrid.Rows[rowIndex].Cells[1].FindControl("txtStartSalary")).Text;
dtCurrentTable.Rows[i]["End_Salary"] = ((TextBox)mdlpopupGrid.Rows[rowIndex].Cells[2].FindControl("txtEndSalary")).Text;
dtCurrentTable.Rows[i]["Increament"] = ((TextBox)mdlpopupGrid.Rows[rowIndex].Cells[3].FindControl("txtIncreament")).Text;
dtCurrentTable.Rows[i]["Frequency"] = ddlFrequency.SelectedValue.ToString();
rowIndex++;
}
This is my Code in Which I assigns the Values of all textboxes & Dropdownlist within mdlpopupGrid into a Datatable...
But the Problem is I dont get the Selectedvalue of Dropdownlist to my Datatable dtCurrentTable
|
|
|
|