|
sumit7034 wrote: I want when user close his browser then all sessions will be disposed.
Do you think it is even a valid design.
What if some other user is still active and you dispose all the sesion when some one closes his browser.
Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
|
|
|
|
|
I want that the all sessions of that user would be abandon who close his browser.
as every browser has different sessions.
I want asp.net sessions to expire on closing the browser.
|
|
|
|
|
//use this code when the page is closed
Session.Abandon();
Padmanabhan
|
|
|
|
|
what if i navigate to other page. or other page is opened in other TAB?
I want to dispose only when browser is closed not on page close.
|
|
|
|
|
k then u are maintaining the session only by login...
so use this Session.Abandon(); in the page load of login before you start assiging the session...
so the session will be killed in the startup...
But if u r opening multiple tabs and closing one tab the session will remain...
so for this u can use query string instead of session
Padmanabhan
|
|
|
|
|
Thats not an Issue. the session will get expire automatically after 30 min
I don't want that server to keep session when browser is closed.
eg when u chat from gmail and if u close the browser u automatically get signed out from the chat.
|
|
|
|
|
Use Session.RemoveAll() in Session_End procedure of Global.asax file
Example
Sub Session_End(ByVal sender As Object, ByVal e As EventArgs)
' Fires when the session ends
Session.RemoveAll()
End Sub
Fareeth
|
|
|
|
|
Hi all,
I have a problem with my rdlc report.When i run the website on my local machine the report works fine. But i get this error message(below) after i deploy the website on to a remote server.
I tried to search but i still cant get the solution. I really need assistance pls.
An error occurred during local report processing.The definition of the report 'Main Report' is invalid.The report definition is not valid. Details: Data at the root level is invalid. Line 1, position 1.
rgds.
allphpro
|
|
|
|
|
It seems that somebody has given a solution in the following links:
Link1[^]
Link2[^]
Hope this will help you.
|
|
|
|
|
Perfect,
Thanks Ramesh.
allphpro
|
|
|
|
|
Hi all,
I having a datatable and i want to export it to word format.In that format i want to define header footer and other type of formatting.
so can any one tell me how to do it.
Thanks in advance.
|
|
|
|
|
assign the datatable in a gridview then give a button as "Export to Word"
//double click the button and write this code
protected void btnword_Click(object sender, EventArgs e)
{
Response.AddHeader("content-disposition", "attachment;filename=Information.doc");
Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.ContentType = "application/vnd.word";
System.IO.StringWriter stringWrite = new System.IO.StringWriter();
System.Web.UI.HtmlTextWriter htmlWrite = new HtmlTextWriter(stringWrite);
// Create a form to contain the grid
HtmlForm frm = new HtmlForm();
GridView1.Parent.Controls.Add(frm);
frm.Attributes["runat"] = "server";
frm.Controls.Add(GridView1);
frm.RenderControl(htmlWrite);
//GridView1.RenderControl(htw);
Response.Write(stringWrite.ToString());
Response.End();
}
Padmanabhan
|
|
|
|
|
No without using gridview i want to do
|
|
|
|
|
u want to export the whole .aspx page to word am i correct.....
Padmanabhan
|
|
|
|
|
No i am having data in datatable with different number of fields.In word i want to display those fields with some different formats like adding the side heading and displaying the records which comes under it and so on...
|
|
|
|
|
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;
public partial class sss : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
private DataTable GenerateDataTable()
{
DataTable dt = new DataTable();
dt.Columns.Add("Id", typeof(int));
dt.Columns.Add("Name", typeof(String));
dt.Columns.Add("Email", typeof(String));
dt.Columns.Add("Gender", typeof(String));
dt.Columns.Add("Salary", typeof(int));
dt.Columns.Add("Image", typeof(String));
DataRow dr = dt.NewRow();
dr["Id"] = 1;
dr["Name"] = "Padmanabhan";
dr["Email"] = "mail2padmanabhan@gmail.com";
dr["Gender"] = "Male";
dr["Salary"] = 10000;
dr["Image"] = "232.jpg";
dt.Rows.Add(dr);
DataRow dr1 = dt.NewRow();
dr1["Id"] = 2;
dr1["Name"] = "Varatharaman";
dr1["Email"] = "varatharaman@gmail.com";
dr1["Gender"] = "Male";
dr1["Salary"] = 20000;
dr1["Image"] = "Photo-0009.jpg";
dt.Rows.Add(dr1);
DataRow dr2 = dt.NewRow();
dr2["Id"] = 3;
dr2["Name"] = "Sathya";
dr2["Email"] = "sathay@gmail.com";
dr2["Gender"] = "Male";
dr2["Salary"] = 10500;
dr2["Image"] = "DSC00010.JPG";
dt.Rows.Add(dr2);
return dt;
}
protected void Button1_Click(object sender, EventArgs e)
{
string fileName = System.Guid.NewGuid().ToString().Replace("-", "") + ".doc";
(new ExportDemo.Libraries.ExcelConvertor()).Convert(GenerateDataTable(), Server.MapPath("."), fileName);
Response.Redirect(fileName);
}
}
//you have to include a .cs file in App_code as WordConvertor.cs and paste this code
using System;
using System.Data;
using System.IO;
using System.Text;
namespace ExportDemo.Libraries
{
/// <summary>
/// To generate excel file.
/// </summary>
public class ExcelConvertor
{
/// <summary>
/// To generate excel file.
/// </summary>
/// <param name="oDataTable"></param>
/// <param name="directoryPath"></param>
/// <param name="fileName"></param>
/// <returns></returns>
public string Convert(DataTable oDataTable, string directoryPath, string fileName)
{
string fullpath = "";
if (directoryPath.Substring(directoryPath.Length - 1,1) == @"\" ||directoryPath.Substring(directoryPath.Length - 1,1) == "/")
{
fullpath = directoryPath + fileName;
}
else
{
fullpath = directoryPath + @"\" + fileName;
}
StreamWriter SW;
SW=File.CreateText(fullpath);
StringBuilder oStringBuilder = new StringBuilder();
/********************************************************
* Start, check for border width
* ******************************************************/
int borderWidth = 0;
if (_ShowExcelTableBorder)
{
borderWidth = 1;
}
/********************************************************
* End, Check for border width
* ******************************************************/
/********************************************************
* Start, Check for bold heading
* ******************************************************/
string boldTagStart = "";
string boldTagEnd = "";
if (_ExcelHeaderBold)
{
boldTagStart = "<B>";
boldTagEnd = "</B>";
}
/********************************************************
* End,Check for bold heading
* ******************************************************/
oStringBuilder.Append("<Table border=" + borderWidth + ">");
/*******************************************************************
* Start, Creating table header
* *****************************************************************/
oStringBuilder.Append("<TR>");
foreach(DataColumn oDataColumn in oDataTable.Columns)
{
oStringBuilder.Append("<TD>" + boldTagStart + oDataColumn.ColumnName + boldTagEnd + "</TD>");
}
oStringBuilder.Append("</TR>");
/*******************************************************************
* End, Creating table header
* *****************************************************************/
/*******************************************************************
* Start, Creating rows
* *****************************************************************/
foreach(DataRow oDataRow in oDataTable.Rows)
{
oStringBuilder.Append("<TR>");
foreach(DataColumn oDataColumn in oDataTable.Columns)
{
if (oDataRow[oDataColumn.ColumnName] is long)
{
oStringBuilder.Append("<TD align=right>" + oDataRow[oDataColumn.ColumnName] + "</TD>");
}
else
{
oStringBuilder.Append("<TD>" + oDataRow[oDataColumn.ColumnName] + "</TD>");
}
}
oStringBuilder.Append("</TR>");
}
/*******************************************************************
* End, Creating rows
* *****************************************************************/
oStringBuilder.Append("</Table>");
SW.WriteLine(oStringBuilder.ToString());
SW.Close();
return fullpath;
}
private bool _ShowExcelTableBorder = false;
/// <summary>
/// To show or hide the excel table border
/// </summary>
public bool ShowExcelTableBorder
{
get
{
return _ShowExcelTableBorder;
}
set
{
_ShowExcelTableBorder = value;
}
}
private bool _ExcelHeaderBold = true;
/// <summary>
/// To make header bold or normal
/// </summary>
public bool ExcelHeaderBold
{
get
{
return _ExcelHeaderBold;
}
set
{
ExcelHeaderBold = value;
}
}
}
}
Padmanabhan
|
|
|
|
|
Hi All.,
I am new to URL rewriting.I am Using IHTTP Handlers to made URL Rewriting.After Rewriting My URL is Looks like as follows Http://localhost/ballistic/Ecards
for the Redirecting page the StyleSheets,Images and .ja file not applying.
This is very urgent for me..pls help on this
|
|
|
|
|
Member 3264122 wrote: This is very urgent for me
Not for me
Member 3264122 wrote: StyleSheets,Images and .ja file not applying
The reference to these resources is not valid anymore after the rewritting.
You should add the reference again during the runtime according tto the structure of your new url.
You can have a look here [^]to see how to add during reference runtime.
Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
|
|
|
|
|
hi.,
Thks for your kind reply.,
Where i have to add the Funtion in my application
|
|
|
|
|
How did you refer your images and script files in your asp.net pages. If the images are in the folder 'Images' and if your refered an image like
Make sure you root qualify CSS, Image and script references.
You have to qualify an image like "/image/yourimage.gif" instead of "image/yourimage.gif".
|
|
|
|
|
Hi.,
Thks for your kind reply.,
All the images and StyleSheet links are as you said.
|
|
|
|
|
Hi there,
I use the following codesnipet to retrieve the user information:
MembershipUser user = Membership.GetUser("username");
but I get this error:
Specified cast is not valid.
any idea?
|
|
|
|
|
This error might occur if your aspnet_ tables have some invalid records or if you edit the aspnet tables directly without using tools like ASP.NET confuguration tool.
Delete the asp_net tables and recreate them.
Hope this will help you.
|
|
|
|
|
MembershipUser user = Membership.GetUser("username");
in this the getuser is a method i think
so u have to cast like the below code
//CheckBox chkBxSelect = (CheckBox)e.Row.Cells[1].FindControl("chkselect");
Padmanabhan
|
|
|
|
|
how to get history of view pages in web application in asp.net ?///////
Piyush Vardhan Singh
p_vardhan14@rediffmail.com
Eventure Technology
http://holyschoolofvaranasi.blogspot.com
http://holytravelsofvaranasi.blogspot.com
|
|
|
|