Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...


What is the difference between Server.Transfer and
Response.Redirect? Why would you choose one over the other?

Answers were Sorted based on User's Feedback



What is the difference between Server.Transfer and Response.Redirect? Why would you choose one over..

Answer / q

StreamReader sr = new StreamReader(@"C:/Documents and
Settings/232838/Desktop/Sample1.txt");

string test = sr.ReadToEnd().Replace("<", "&lt;").Replace
(">", "&gt;");

Is This Answer Correct ?    1 Yes 1 No

What is the difference between Server.Transfer and Response.Redirect? Why would you choose one over..

Answer / b

xcopy /Y "D:\Bala\General\HIS_CLAIM.doc" "D:\"

Is This Answer Correct ?    1 Yes 1 No

What is the difference between Server.Transfer and Response.Redirect? Why would you choose one over..

Answer / xy

Set exCon = Server.CreateObject( "ADODB.Connection" )
Set dbCon = Server.CreateObject
( "ADODB.Connection" )

'open connection to excel
'had to use the JET driver since some of
the ODBC functionality didnt work
exCon.ConnectionTimeout = 30
' exCon.open "Driver={Microsoft Excel Driver
(*.xls)};Dbq=" & Filepath & ";UID=admin;TypeGuessRows=0;"

exCon.open "Provider=Microsoft.Jet.OLEDB.4.0;Data
Source=" & Filepath & ";Extended Properties=""Excel
8.0;IMEX=1;ImportMixedTypes=Text;TypeGuessRows=0"""

exCon.CommandTimeout = 90

'open connection to DB
openDBConnection(dbCon)

set rs=exCon.OpenSchema(20)
strPageName = rs(2)
'ADO replaces a ' with a '' by default. we
need to undo this change during the import.
if instr(strPageName, "''") > 0 then
response.write "The name of the
Spreadsheet tab cannot have a comma. "
response.write "The current name
["& replace(strPageName,"''","'") &"] must be corrected
before it can be uploaded.<BR>"
response.End()
end if

response.write "Page <B>" & strPagename
& "</B> was imported"

rs.close
set rs=nothing
Set RS = Server.CreateObject
("ADODB.Recordset")
RS.ActiveConnection = exCon
RS.CursorType =
1
RS.LockType =
1
RS.Source = "SELECT * FROM [" &
strPageName & "] where siteno is not null and projcode = '"
& strProjCode & "'"
RS.Open
if not rs.eof then
arrData = rs.getrows()
else

response.redirect "/error.asp?msg=Template Projcode
Mismatch ! (" & Request.ServerVariables("URL") & ")"
response.end
end if

Is This Answer Correct ?    1 Yes 1 No

What is the difference between Server.Transfer and Response.Redirect? Why would you choose one over..

Answer / d

using System.Data.OleDb;

string strFilePath = @"D:\Development\Test.xlsx";
try {
string strConnectionString = string.Empty;
//strConnectionString =
@"Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" +
strFilePath + @";Extended Properties=""Excel
8.0;HDR=YES;IMEX=1""";
strConnectionString =
@"Provider=Microsoft.ACE.OLEDB.12.0;Data Source=" +
strFilePath + @";Extended Properties=""Excel 12.0
Xml;HDR=YES;IMEX=1""";
OleDbConnection cnCSV = new OleDbConnection
(strConnectionString);
cnCSV.Open();
OleDbCommand cmdSelect = new OleDbCommand
(@"SELECT * FROM [Sheet1$]", cnCSV);
OleDbDataAdapter daCSV = new OleDbDataAdapter();
daCSV.SelectCommand = cmdSelect;
DataTable dtCSV = new DataTable();
daCSV.Fill(dtCSV);
cnCSV.Close();
daCSV = null;

Response.Write(dtCSV.Rows.Count);
gvTest.DataSource = dtCSV;
gvTest.DataBind();


} catch (Exception ex) {
} finally {
}


<asp:GridView ID="gvTest" runat="server"
AutoGenerateColumns="false">
<Columns>
<asp:BoundField HeaderText="GDCID" DataField="GDCID" />
<asp:BoundField HeaderText="EmpID" DataField="EmpID" />
</Columns>
</asp:GridView>

Is This Answer Correct ?    1 Yes 1 No

What is the difference between Server.Transfer and Response.Redirect? Why would you choose one over..

Answer / d

Put it inside <configuration> section

<connectionStrings>
<add key="conString" value="server=01HW154261\SQLEXPRESS;
database=MyDB; user id=; password=;" />
</connectionStrings>

SqlConnection con = new SqlConnection();

con.ConnectionString = ConfigurationManager.AppSettings
["conString"].ToString();

con.Open();

SqlDataAdapter adapter = new SqlDataAdapter("Select a.State
From State as a inner join Country as b on a.CountryID =
b.CountryID where b.CountryID = " + countryID, con);

DataSet dstCountry = new DataSet();

adapter.Fill(dstCountry);

con.Close();

Is This Answer Correct ?    0 Yes 0 No

What is the difference between Server.Transfer and Response.Redirect? Why would you choose one over..

Answer / x

using System;
using System.Data;
using System.Configuration;
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;
using System.Data.SqlClient;

public partial class _Default : System.Web.UI.Page
{
public string qry = string.Empty;
public SqlDataAdapter dap = null;
public DataSet dst = null;
public string proj;
public string mod;

protected void Page_Load(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection();
con.ConnectionString =
ConfigurationManager.ConnectionStrings
["Connection"].ToString();
con.Open();

string sql = string.Empty;
string projCode = string.Empty;
string moduleID = string.Empty;

if (!IsPostBack)
{
qry = "Select Projcode from Etmtech.dbo.Project
where edgesupported = 1 and libraryname = 'recon' order by
projcode";
dap = new SqlDataAdapter(qry, con);
dst = new DataSet();
dap.Fill(dst);

selProject.DataSource = dst;
selProject.DataTextField = dst.Tables[0].Columns
["Projcode"].ToString().ToUpper();
selProject.DataBind();

dap.Dispose();
dst.Dispose();

qry = "Select clientname,clientid from
etmtech.dbo.client (nolock) order by clientid";
dap = new SqlDataAdapter(qry, con);
dst = new DataSet();
dap.Fill(dst);

selClient.DataSource = dst;
selClient.DataTextField = dst.Tables[0].Columns
["clientname"].ToString();
selClient.DataValueField = dst.Tables[0].Columns
["clientid"].ToString();
selClient.DataBind();

dap.Dispose();
dst.Dispose();

}

projCode = selProject.SelectedValue.ToString();

if(Session["projCode"] == null || !projCode.Equals
(Session["projCode"].ToString()))
{
qry = string.Empty;
qry = "Select descr,moduleid from
Recon.dbo.Recon_Menu (Nolock) where projcode = '" +
selProject.SelectedItem.Text + "'";
dap = new SqlDataAdapter(qry, con);
dst = new DataSet();
dap.Fill(dst);

selModule.DataSource = dst;
selModule.DataValueField = dst.Tables[0].Columns
["moduleid"].ToString();
selModule.DataTextField = dst.Tables[0].Columns
["descr"].ToString();
selModule.DataBind();

dap.Dispose();
dst.Dispose();

Session["projCode"] = projCode;
}

moduleID = selModule.SelectedValue;

if (!moduleID.Equals(string.Empty))
{
qry = string.Empty;
qry = "select
o.objectorder,o.descr,pt.name,p.parmvalue from
recon.dbo.recon_object o (nolock)";
qry = qry + " ,recon.dbo.recon_parameter p
(nolock),recon.dbo.recon_lu_parametertype pt (nolock)";
qry = qry + " where o.moduleid =" +
Convert.ToInt32(moduleID) + " and o.objectid = p.objectid
and p.parmtypeid = pt.parmtypeid order by o.objectorder";
dap = new SqlDataAdapter(qry, con);
dst = new DataSet();
dap.Fill(dst);

GVobj.DataSource = dst;
GVobj.DataBind();

if (dst.Tables[0].Rows.Count > 0)
{
btSave.Enabled = true;
btCancel.Enabled = true;
}

dap.Dispose();
dst.Dispose();

}

string client = selClient.SelectedValue.ToString();

}

protected void GVobj_RowDataBound(object sender,
GridViewRowEventArgs e)
{
if (e.Row.RowIndex == 0)
{
proj = e.Row.Cells[1].Text;
}

if (e.Row.RowIndex > 0)
{
if (proj.Equals(e.Row.Cells[1].Text))
{
e.Row.Cells[1].Text = "";
}
}
}
}

Is This Answer Correct ?    0 Yes 0 No

What is the difference between Server.Transfer and Response.Redirect? Why would you choose one over..

Answer / x

using System;
using System.Data;
using System.Configuration;
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;
using System.Data.SqlClient;
public partial class _Default : System.Web.UI.Page
{
public SqlDataAdapter dap = null;
public DataSet dst = null;
public string projDesc = string.Empty;
public string divisionName = string.Empty;
protected void Page_Load(object sender, EventArgs e)
{
SqlConnection con = new SqlConnection();
con.ConnectionString =
ConfigurationManager.ConnectionStrings["conString"].ToString
();
con.Open();
string sql = string.Empty;
string projCode = string.Empty;
string divisionCode = string.Empty;

if (!IsPostBack)
{
dap = new SqlDataAdapter("select * from
Project", con);
dst = new DataSet();
dap.Fill(dst);
ddlProject.DataSource = dst;
ddlProject.DataValueField = dst.Tables
[0].Columns["ProjCode"].ToString();
ddlProject.DataTextField = dst.Tables[0].Columns
["ProjDesc"].ToString();
ddlProject.DataBind();
dap.Dispose();
dst.Dispose();
}
projCode = ddlProject.SelectedValue.ToString();
if (Session["projCode"] == null || !projCode.Equals
(Session["projCode"].ToString()))
{
sql = "select * from Division where ProjCode
= " + Convert.ToInt32(projCode);
dap = new SqlDataAdapter(sql, con);
dst = new DataSet();
dap.Fill(dst);
ddlDivision.DataSource = dst;
ddlDivision.DataValueField = dst.Tables
[0].Columns["DivisionID"].ToString();
ddlDivision.DataTextField = dst.Tables
[0].Columns["DivisionName"].ToString();
ddlDivision.DataBind();
dap.Dispose();
dst.Dispose();
Session["projCode"] = projCode;
}
divisionCode = ddlDivision.SelectedValue.ToString();
if (!divisionCode.Equals(string.Empty))
{
sql = "select a.ProjDesc, b.DivisionName,
c.MemberName from Project a inner join Division b on
a.ProjCode = b.ProjCode ";
sql += "inner join Member c on b.DivisionID =
c.DivisionID where a.ProjCode = " + Convert.ToInt32
(projCode);
sql += " and b.DivisionID = " + Convert.ToInt32
(divisionCode);
dap = new SqlDataAdapter(sql, con);
dst = new DataSet();
dap.Fill(dst);
gvProj.DataSource = dst;
gvProj.DataBind();
dap.Dispose();
dst.Dispose();
}
con.Close();
}

protected void gvProj_RowDataBound(object sender,
GridViewRowEventArgs e)
{
gvRowCheck(e);
}
private void gvRowCheck(GridViewRowEventArgs e)
{
if (e.Row.RowIndex == 0)
{
projDesc = e.Row.Cells[0].Text;
divisionName = e.Row.Cells[1].Text;
}
if (e.Row.RowIndex > 0)
{
if (projDesc.Equals(e.Row.Cells[0].Text))
{
e.Row.Cells[0].Text = "";
}
if (divisionName.Equals(e.Row.Cells[1].Text))
{
e.Row.Cells[1].Text = "";
}
}
}

}

Is This Answer Correct ?    0 Yes 0 No

What is the difference between Server.Transfer and Response.Redirect? Why would you choose one over..

Answer / d

/* Default.aspx */

<div>
<asp:DropDownList ID="ddlProject" runat="server"
AutoPostBack="true"></asp:DropDownList>
<asp:DropDownList ID="ddlDivision" runat="server"
AutoPostBack="true"></asp:DropDownList>
<asp:GridView ID="gvMember" runat="server"
AutoGenerateColumns="false"
OnRowDataBound="gvMember_RowDataBound">
<Columns>
<asp:BoundField DataField="ProjDesc"
HeaderText="Project Name" />
<asp:BoundField DataField="DivisionName"
HeaderText="Division Name" />
<asp:BoundField DataField="MemberID" HeaderText="Member
ID" />
<asp:BoundField DataField="MemberName"
HeaderText="Member Name" />
</Columns>
</asp:GridView>
</div>

/* Default.aspx.cs */

using System;
using System.Data;
using System.Configuration;
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;
using System.Data.SqlClient;

public partial class _Default : System.Web.UI.Page
{
public string projDesc = string.Empty;
public string divisionName = string.Empty;


protected void Page_Load(object sender, EventArgs e) {
string projCode = string.Empty;
string divisionID = string.Empty;

if (!IsPostBack) {
PopulateData.LoadProject(ddlProject);
}

projCode = ddlProject.SelectedValue.ToString();

if (Session["projCode"] == null || !projCode.Equals
(Session["projCode"].ToString())) {
PopulateData.LoadDivision(ddlDivision,
projCode);
Session["projCode"] = projCode;
}

divisionID = ddlDivision.SelectedValue.ToString();

if (!divisionID.Equals(string.Empty)) {
gvMember.DataSource =
PopulateData.LoadMemberDetails(projCode, divisionID);
gvMember.DataBind();
}
}


protected void gvMember_RowDataBound(object sender,
GridViewRowEventArgs e) {
if (e.Row.RowIndex == 0) {
projDesc = e.Row.Cells[0].Text;
divisionName = e.Row.Cells[1].Text;
}

if (e.Row.RowIndex > 0) {
if (projDesc.Equals(e.Row.Cells[0].Text)) {
e.Row.Cells[0].Text = "";
}

if (divisionName.Equals(e.Row.Cells[1].Text)) {
e.Row.Cells[1].Text = "";
}
}
}
}

/* Populate.cs */

using System;
using System.Data;
using System.Configuration;
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;

/// <summary>
/// Summary description for PopulateData
/// </summary>
public class PopulateData
{
public PopulateData()
{
//
// TODO: Add constructor logic here
//
}

public static DataSet LoadProject() {
string query = string.Empty;
query = "select * from Project";
DataSet dst = Data.getDataSet(query);
return dst;
}

public static void LoadProject(DropDownList ddlProject)
{
string query = string.Empty;
query = "select * from Project";
DataSet dst = Data.getDataSet(query);
ddlProject.DataSource = dst;
ddlProject.DataValueField = dst.Tables[0].Columns
["ProjCode"].ToString();
ddlProject.DataTextField = dst.Tables[0].Columns
["ProjDesc"].ToString();
ddlProject.DataBind();
dst.Dispose();
}

public static DataSet LoadDivision(string projCode) {
string query = string.Empty;
query = "select * from Division where ProjCode = "
+ Convert.ToInt32(projCode);
DataSet dst = Data.getDataSet(query);
return dst;
}

public static void LoadDivision(DropDownList
ddlDivision, string projCode) {
string query = string.Empty;
query = "select * from Division where ProjCode = "
+ Convert.ToInt32(projCode);
DataSet dst = Data.getDataSet(query);
ddlDivision.DataSource = dst;
ddlDivision.DataValueField = dst.Tables[0].Columns
["DivisionID"].ToString();
ddlDivision.DataTextField = dst.Tables[0].Columns
["DivisionName"].ToString();
ddlDivision.DataBind();
dst.Dispose();
}

public static DataSet LoadMemberDetails(string
projCode, string divisionID) {
string query = string.Empty;
query = "select c.ProjDesc, b.DivisionName,
a.MemberID, a.MemberName from Member a";
query += " inner join Division b on a.DivisionID =
b.DivisionID";
query += " inner join Project c on b.ProjCode=
c.ProjCode";
query += " where a.ProjCode = " + Convert.ToInt32
(projCode) + " and a.DivisionID = " + Convert.ToInt32
(divisionID);
DataSet dst = Data.getDataSet(query);
return dst;
}
}

/* Connection.cs */

using System;
using System.Data;
using System.Configuration;
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;
using System.Data.SqlClient;

/// <summary>
/// Summary description for Connection
/// </summary>
public class Connection
{
public Connection()
{
//
// TODO: Add constructor logic here
//
}

public static SqlConnection OpenConnection
(SqlConnection con) {
con.ConnectionString =
ConfigurationManager.ConnectionStrings["conString"].ToString
();
con.Open();
return con;
}

public static void CloseConnection(SqlConnection con){
if (con.State == ConnectionState.Open) {
con.Close();
}
}
}

/* Data.cs */

using System;
using System.Data;
using System.Configuration;
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;
using System.Data.SqlClient;

/// <summary>
/// Summary description for Data
/// </summary>
public class Data
{
public Data()
{
//
// TODO: Add constructor logic here
//
}

public static DataSet getDataSet(string query) {
SqlConnection con = new SqlConnection();
DataSet dst = new DataSet();
SqlDataAdapter dap = new SqlDataAdapter(query,
Connection.OpenConnection(con));
dap.Fill(dst);
Connection.CloseConnection(con);
return dst;
}
}

Is This Answer Correct ?    0 Yes 0 No

What is the difference between Server.Transfer and Response.Redirect? Why would you choose one over..

Answer / s

http://www.codeproject.com/KB/webforms/NingLiangSimpleContro
l.aspx

Is This Answer Correct ?    0 Yes 0 No

What is the difference between Server.Transfer and Response.Redirect? Why would you choose one over..

Answer / rao

server.transfer is transfer to with in the application
pages.but responce.redirect can transfer to any page.
ex
response.redirect("www.google.com");
it is not work for server.transfer.

Is This Answer Correct ?    0 Yes 0 No

Post New Answer

More ASP.NET Interview Questions

What method must be overridden in a custom control? a) The Paint() method b) The Control_Build() method c) The Render() method d) The default constructor

1 Answers   Icertis, Microsoft, Syntax Softtech,


What are the modes of updation in an updatepanel? What are triggers of an updatepanel?

0 Answers  


Is asp.net 64-bit enabled? How?

0 Answers  


What is the difference between WindowsDefaultLocation and WindowsDefaultBounds?

0 Answers   BirlaSoft,


Can One website be made using two different languages like c#,vb.net etc......

4 Answers   ABC,


what is session ?how sessions are handeled in application? write the clauses of sql server in their order.

3 Answers   Olive Tech,


Distinguish between Server-side and Client-side code?

0 Answers   Siebel,


Why is validation always done on the server? When does that occur?

2 Answers  


suppose i am Admin in my application and i have to terminate the session of the particular user in my application.........how can i do it....?????

1 Answers   L&T,


Explain the steps to be followed to use passport authentication.

0 Answers  


How Can assign alias name for ASP.NET Web API Action?

0 Answers  


What is custom tag in Web.Config?

0 Answers   Accenture,


Categories