473,466 Members | 1,389 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

PostBack IFrame src issue

I have a page which has an IFrame on it. The src of the
IFrame is a page with a datagrid on it. The Datagrid has
bound template columns. The columns of the datagrid pass
the bound data value of each cell within it to my code
behind file which generates the HTML to display the data
in a formatted text box, some of which is editable, some
of which is not. The idea here is that the user can look
at a page with a scrolling 'window'. Move through the
editable HTML textboxes in the datagrid displayed in the
scrolling widow, then save all changes en-mass. This is
achieved, the datagrid having some zero width columns
which hold the original values that were in the editable
text boxes also. Basically, each editable field is
retrieved twice from the database, one is displayed as
editable to the user, one is hidden but holds the original
value.
I can achieve a PostBack event for the src of the IFrame
thru' javascript on either an asp.Net or HTML control.

In the Page Load event of the src of the IFrame, I
retrieve the ID values from the datagrid, iterate through
them, getting the editable and original values from the
datagrid, comparing them and saving records where there is
a difference. However, here I have an od issue.

On some machines, sometimes changes aren't saved. I cannot
replicate this on my dev machine, (win 2000 server) or on
a win 95 machine located close to me. It is frequently but
inconsistently replicable on a number of Win NT machines
some 500 miles away from me and on a win xp pro machine
also that distance away. It cannot be replicated on a Win
2003 server .Net development machine that is that
geographically seperated from me. NB: My dev machine is
acting as the Web Server.

The Page_Load event of the IFrame src is below.
<CODE>
private void Page_Load(object sender,
System.EventArgs e)
{/* Validate authentic users */
try
{
if (Session
["Authd"].ToString() == "true")
{
try
{
if (Session
["Role"].ToString() == "compliance")
{
}
else
{

Server.Transfer("frmLogin.aspx");
}
}
catch
(NullReferenceException)
{
Session
["Authd"] = "false";

Server.Transfer("frmLogin.aspx");
}
}
else if (Session
["Authd"].ToString() == "false")
{
Server.Transfer
("frmLogin.aspx");
}
else
{
Session["Authd"]
= "false";
Server.Transfer
("frmLogin.aspx");
}
}
catch (NullReferenceException)
{
Session["Authd"] = "false";
Server.Transfer
("frmLogin.aspx");
}

if (IsPostBack)
{
string[] ID = Request.Form
["txtID"].ToString().Split (',');
int i = 0;

if (Session
["PositionChange"] != null)
{
Session.Add
("PositionChange",0);
}

string MonthlyPeriod =
Dates.GetCCYYMM(DateTime.Now.ToLocalTime());
string UserName = Session
["UserName"].ToString();
for (i=0;i< ID.Length ;i++)
{
// try
// {
int CPID =
Convert.ToInt32(ID[i]);
double
GasPayment = Convert.ToDouble(Request.Form["txtGasPayment"
+ ID[i]].ToString());
double
TotalGasPayments = Convert.ToDouble(Request.Form
["txtTotalPaymentsGas" + ID[i]].ToString());
double
ElectricityPayment = Convert.ToDouble(Request.Form
["txtElectricityPayment" + ID[i]].ToString());
double
TotalElectricityPayments = Convert.ToDouble(Request.Form
["txtTotalPaymentsElectricity" + ID[i]].ToString());
double
OtherPayment = Convert.ToDouble(Request.Form
["txtOtherPayment" + ID[i]].ToString());
double
TotalOtherPayments = Convert.ToDouble(Request.Form
["txtTotalPaymentsOther" + ID[i]].ToString());
double
Overdue = Convert.ToDouble(Request.Form["txtOutstanding" +
ID[i]].ToString());
double
TotalOverdue = Convert.ToDouble(Request.Form
["txtTotalOutstanding" + ID[i]].ToString());
int
PositionChange = Convert.ToInt32(Session
["PositionChange"].ToString());

if
(GasPayment != TotalGasPayments)
{
if
(Session["PositionChange"] != null)
{

Session["PositionChange"] = Convert.ToInt32(Session
["PositionChange"].ToString()) + 1;
}

else
{

Session.Add("PositionChange",1);
}
double PaymentAmount = GasPayment-TotalGasPayments;

string strSQL = "proc_UpdateFuelPayments " +

"@CPID = " + CPID + ", " +

"@Commodity = 1, " +

"@TotalAmount = " + GasPayment + ", " +

"@PaymentAmount = " + PaymentAmount + ", " +

"@MonthlyPeriod = '" + MonthlyPeriod + "', " +

"@AuditUser = '" + UserName + "'";

SqlCommand InsertGasPayment = new SqlCommand
(strSQL, cnSQLLogin);

InsertGasPayment.Connection.Open();

InsertGasPayment.ExecuteNonQuery();

InsertGasPayment.Connection.Close();
}

if
(ElectricityPayment != TotalElectricityPayments)
{
if
(Session["PositionChange"] != null)
{

Session["PositionChange"] = Convert.ToInt32(Session
["PositionChange"].ToString()) + 1;
}

else
{

Session.Add("PositionChange",1);
}

double PaymentAmount = ElectricityPayment-
TotalElectricityPayments;
string strSQL = "proc_UpdateFuelPayments " +

"@CPID = " + CPID + ", " +

"@Commodity = 2, " +

"@TotalAmount = " + ElectricityPayment + ", " +

"@PaymentAmount = " + PaymentAmount + ", " +

"@MonthlyPeriod = '" + MonthlyPeriod + "', " +

"@AuditUser = '" + UserName + "'";

SqlCommand InsertElectricityPayment = new
SqlCommand(strSQL, cnSQLLogin);

InsertElectricityPayment.Connection.Open();

InsertElectricityPayment.ExecuteNonQuery();

InsertElectricityPayment.Connection.Close();
}

if
(OtherPayment != TotalOtherPayments)
{
if
(Session["PositionChange"] != null)
{

Session["PositionChange"] = Convert.ToInt32(Session
["PositionChange"].ToString()) + 1;
}

else
{

Session.Add("PositionChange",1);
}

double PaymentAmount = OtherPayment-
TotalOtherPayments;
string strSQL = "proc_UpdateFuelPayments " +

"@CPID = " + CPID + ", " +

"@Commodity = 3, " +

"@TotalAmount = " + OtherPayment + ", " +

"@PaymentAmount = " + PaymentAmount + ", " +

"@MonthlyPeriod = '" + MonthlyPeriod + "', " +

"@AuditUser = '" + UserName + "'";

SqlCommand InsertOtherPayment = new SqlCommand
(strSQL, cnSQLLogin);

InsertOtherPayment.Connection.Open();

InsertOtherPayment.ExecuteNonQuery();

InsertOtherPayment.Connection.Close();
}

if
(Overdue != TotalOverdue)
{
if
(Session["PositionChange"] != null)
{

Session["PositionChange"] = Convert.ToInt32(Session
["PositionChange"].ToString()) + 1;
}

else
{

Session.Add("PositionChange",1);
}

double Difference = Overdue - TotalOverdue;

string strSQL = "proc_UpdateOverdue " +

"@CPID = " + CPID + ", " +

"@MonthlyPeriod = '" + MonthlyPeriod + "', " +

"@Overdue = " + Overdue + ", " +

"@Difference = " + Difference + ", " +

"@AuditUser = '" + UserName + "'";

SqlCommand UpdateOverdue = new SqlCommand(strSQL,
Connection.Connect());

UpdateOverdue.Connection.Open();

UpdateOverdue.ExecuteNonQuery();

UpdateOverdue.Connection.Close();
}

if
(PositionChange < Convert.ToInt32(Session
["PositionChange"].ToString()))
{

string strSQL = "UPDATE tbl_CounterpartyCalcs " +

"SET BalanceDue = COALESCE(((cpc.Overdue +
cpc.DueThisMonth) - cpc.PaymentsMadeReceived),0) " +

"FROM tbl_CounterpartyCalcs cpc " +

"WHERE cpc.CounterpartyId = " + CPID + " " +

"AND cpc.MonthlyPeriod = '" + MonthlyPeriod + "'";

SqlCommand BalanceDue = new SqlCommand(strSQL,
Connection.Connect());

BalanceDue.Connection.Open();

BalanceDue.ExecuteNonQuery();

BalanceDue.Connection.Close();
strSQL = "EXEC sp_Calc_Exposure_CPT " +

"@pFutureYears = 2, " +

"@pCPT = " + CPID + ", " +

"@Result = 0";
SqlCommand UpdateCPPosition = new SqlCommand
(strSQL, cnSQLLogin);

UpdateCPPosition.Connection.Open();

UpdateCPPosition.ExecuteNonQuery();

UpdateCPPosition.Connection.Close();
}
// }
// catch (Exception)
// {
//
Connection.CloseConnection(cnSQLLogin);
// }
}

Session.Add
("PopulateCommodity",0);
}

// Put user code to initialize the
page here

daPayments.SelectCommand.CommandText = "EXEC
proc_Select_PaymentsDue @Commodity = " + Session
["PopulateCommodity"].ToString();

daPayments.SelectCommand.Connection = cnSQLLogin;
daPayments.Fill
(dsNewPayment.tbl_Payment);
Session.Add("PopulateCommodity",0);

// Bind MyDataGrid to the DataSet
DataView s = new DataView
(dsNewPayment.tbl_Payment);
dgPayments.DataSource = s;
dgPayments.DataBind();
}
</CODE>

It validates the user, checks if this is a postback event,
and if it is validdates and saves changes between records,
then reloads the data.

Does anyone have any clues, or is it possible, as I
suspect, that on occassion my error is being caused by the
Top level page with the IFrame on it doing it's postback
first, which I think would simply refresh the data on the
IFrame src as it wouldn't be a PostBack for this page.
This would then postback after the first page and of
course there are no changes to the data as it's just been
reloaded from the database...

....or could this just be an IE bug, or something else
again...

....all help appreciated.
Nov 17 '05 #1
1 4678
Hello,

When the parent webform is postback, its child webform (in iFrame) wouldn't
be post back, it only be reloaded. Anyway, since the problem was only found
on several computer, this didn't seem to be the root cause.

I found you have some try..catch statement in the code, so that user may
not see a raw error. The problem may also occur when writng data to
database. I suggest may add some debug code into the Catch statement. For
example, add the error information to System event log.For detail on this,
you may refer to :

HOW TO: Write to an Event Log by Using Visual C# .NET
http://support.microsoft.com/default...;EN-US;Q307024

You also can log the client's IP and computer name to see if the error came
from the particualr computers:

Request.UserHostName
Request.UserHostAddress

Hope this help.

Luke
Microsoft Online Partner Support

Get Secure! www.microsoft.com/security)
This posting is provided "AS IS", with no warranties, and confers no

ights.)

Nov 17 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: deepika | last post by:
Hi, I have a datagrid with 200 rows and an iframe adjacent to it. When I click on the row, the details of that row show up in the iframe. Now suppose I click on the 150th row, the postback occurs...
1
by: Jason | last post by:
Hi I have client side script that inserts an IFrame into a table cell upon a particular client side click event. My problem is that when a postback occurs, that IFrame "disappears". what do i do...
3
by: Guogang | last post by:
In a .aspx web page, I created a button that will do a postback What I want to do: let the button do postback, and process the postback data in my code behind, but the client side's page won't be...
4
by: Richard St?en | last post by:
Hi! We are experiencing a problem with running an .aspx page inside an iframe. The .aspx page is loading perfectly the first time (on load), but when we try to interact/navigate within the .aspx...
7
by: moondaddy | last post by:
I'm building a page in vb.net with several user controls on it. I'm using user controls instead of a frames page since I've seen this recommended many times in this user group. I want just one of...
2
by: Carter | last post by:
i have a treeview on a webform (.aspx). when the user selects an appropriate node on the tvw. and clicks on a link button, i'm downloading a corresponding file to the client (from the server). so far...
3
by: Ashish | last post by:
Hello All, This is a bit wierd. I have a main page in my webapp that has toolbar to carry out some common operations. Also this main page has an iframe that hosts a page that serves as an...
4
by: Mervin Williams | last post by:
Postbacks cause a webform to re-display the page at the top. Well, I have a fairly long form and would like the page display to be re-positioned where the user clicked the button that caused the...
1
by: Christian Nunciato | last post by:
Hi there: I've checked the forums, but haven't found a situation addressing my specific problem. Here's the deal: I've got a Web Form containing two Panel controls. One displays search...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.