|
I'm really fighting this issue where Firefox is loading my pages twice. Running through the debugging of the pages, my OnInit and Page_Load events are executed twice. This only happens using FireFox, IE7 loads the pages properly. I've been researching the issue and found all the normal "Empty image src" posts and even tried the AutoEventWireup being set to false, and none have resolved my issue. It's causing me all sorts of problems, double emails, double database entries being written, etc. Please can someone just point me in some direction? I would be very grateful.
I'm using VS Team Suite SP1, 3.5 SP1 of the framework and FireFox 3.07. Here is my simple most stripped down test page that the issue is still occurring on.
<![CDATA[<%@ Page Language="C#" AutoEventWireup="false" CodeBehind="WebForm2.aspx.cs" Inherits="RSD.DADS.Web.WebForm2" %>]]>
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:label id="Label1" runat="server" text="1" xmlns:asp="#unknown"></asp:label>
<br />
<asp:label id="Label2" runat="server" text="2" xmlns:asp="#unknown"></asp:label>
<br />
<asp:label id="Label3" runat="server" text="3" xmlns:asp="#unknown"></asp:label>
<br />
<asp:label id="Label4" runat="server" text="4" xmlns:asp="#unknown"></asp:label>
</div>
</form>
</body>
</html>
And the CodeBehind:
using System;
namespace RSD.DADS.Web
{
public partial class WebForm2 : System.Web.UI.Page
{
override protected void OnInit(EventArgs e)
{
this.Load += new System.EventHandler(this.Page_Load);
}
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
FillLabel1();
FillLabel3();
FillLabel4();
}
}
private void FillLabel1()
{
Label1.Text = "From FillLabel1()";
FillLabel2();
}
private void FillLabel2()
{
Label2.Text = "From FillLabel2()";
}
private void FillLabel3()
{
Label3.Text = "From FillLabel3()";
}
private void FillLabel4()
{
Label4.Text = "From FillLabel4()";
}
}
}
modified on Wednesday, March 18, 2009 2:52 PM
|
|
|
|
|
Well I was able to stop the page from loading twice in Firefox. All the outputted HTML validated just fine using FireBug, but then just on a whim, I decided to remove the DOCTYPE line.
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
and page only ran through once. I didn't think that the "XHTML 1.0 Transitional" would have been strict enough to cause this. So I tried using
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
then tried
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML Basic 1.0//EN" "http://www.w3.org/TR/xhtml-basic/xhtml-basic10.dtd">
Neither stopped FireFox from loading the page twice. So far the only way that the page is not running through the Page_Load twice, is if I remove the DOCTYPE all together.
Any thoughts as to why this would be happening?
|
|
|
|
|
just remove below code in oninit event and try.....
this.Load += new System.EventHandler(this.Page_Load);
|
|
|
|
|
Out of interest, why did you add the oninit event? That is your problem, cause it runs the oninit event which fires the page_load event, and then the page loads which then executes the Page_loads event again, because it is two different events and not a post back your IsPostBack check will return false causing your fill methods to run twice (Once on the oninit and once on the page_load).
No matter how long he who laughs last laughs, he who laughs first has a head start!
|
|
|
|
|
The problem occurs with or without the onInit event. The issue happened prior to my adding of the onInit. I added that once I changed my AutoEventWireup property to false, which was a frequently found suggestion. Once it was changed to false, I then had to declare the page_load event or it (page_load) never executed.
Did you happen to take the code and run through debugging it with FireFox 3.0.7? Does it not execute the page twice? The only way that I was able to make the page stop executing the whole page two times was to remove the DOCTYPE declaration.
Thanks for your input.
|
|
|
|
|
I have a strange problem (imho).
I have a gridview and in this gridview it is possible to have DateTime and Decimal objects.
In the database we have stored the format in which these fields should be showed like 'dd MMM yyyy HH:mm' for a DateTime.
But our customer wants to be able to change that formatstring in the database and in the gridview the new choosen formatstring should be applied after a refresh of the grid.
The issue is this.
In the OnRowDataBound event of the grid I call a Method to determine the original datatype of the cellvalue.
I can find that datatype in the DataRowView GetType. And if it is System.DateTime, I can put the value in a datetime object. But then...
How do I know which Cell in the GridView holds this DataRowView value so I could change the TableCell Text property with the value formatted to the formatstring which is found in the database ?
Extra problem:
the dataRowView[0] holds the DataKeyValue for the gridviewrow (needed when selcting or editing).
But tableCell[0] is not always dataRowView[1] because we do not always use all the fields in the dataRowView.
Or is there a better way to solve this?
|
|
|
|
|
I would suggest setting the Date format as a user preference in your application as opposed to allowing the user to update the data in the database. This would be the easiest way to allow this change on your page and would also keep your database from having multiple date values. Here is an article that may assist you in setting up application/user settings.
http://msdn.microsoft.com/en-us/library/aa730869(VS.80).aspx[^]
Hope this helps.
Matthew Vass
QA Analyst
mvass@hostmysite.com
http://www.hostmysite.com?utm_source=bb[^]
|
|
|
|
|
Hello Matthew,
this is not what I am looking for.
There is only 1 setting for al users. It is not attached to user but to datatype.
Any one else who knows how to find the link between datarowview value and tablecell value and the filling on the fly of the dataformatstring of the gridview?
In Word you can only store 2 bytes. That is why I use Writer.
|
|
|
|
|
Having it fixed
This is the trick
1. Determine for each gridviewcolumn its headertext
2. Determine for each cell in the row.cells if the cell.ContainingField.HeaderText equals the headertext found in the previous gridviewcolumn
3. If the value of an item in the array of the datarowview with (yeah I know it can be buggy) the cell.text value you have found it
Than determine the type of the dataRowView[x] and fill cell.text with the formatstring in the Database.
Anyone a better solution ?
see my code:
public static GridViewRow MaakGridViewRowOp(GridViewRow row)
{
GridView grid = (GridView)row.NamingContainer;
DataRowView dataRow = (DataRowView)row.DataItem;
foreach (DataControlField column in grid.Columns)
{
foreach (DataControlFieldCell cell in row.Cells)
{
if (column.HeaderText.Equals(cell.ContainingField.HeaderText)
&& !String.IsNullOrEmpty(column.HeaderText))
{
for (int celwaarde = 1; celwaarde < dataRow.Row.ItemArray.Length; celwaarde++)
{
if (cell.Text.StartsWith(dataRow[celwaarde].ToString(),
StringComparison.OrdinalIgnoreCase))
{
if (dataRow[celwaarde].GetType().Equals(Type.GetType("System.DateTime")))
{
DateTime datum = Convert.ToDateTime(dataRow[celwaarde]);
cell.Text = datum.ToString(MSBNZBLL.ParameterString.
SysteemParameters.GetParameterAsString("DatumTijdFormat"));
}
else if (dataRow[celwaarde].GetType().Equals(Type.GetType("System.Decimal")))
{
Decimal getal = Convert.ToDecimal(dataRow[celwaarde]);
cell.Text = getal.ToString(MSBNZBLL.ParameterString.
SysteemParameters.GetParameterAsString("VerwerkteMetingFormat"));
}
else if (dataRow[celwaarde].GetType().Equals(Type.GetType("System.Int32")))
{
Decimal getal = Convert.ToDecimal(dataRow[celwaarde]);
cell.Text = getal.ToString(MSBNZBLL.ParameterString.
SysteemParameters.GetParameterAsString("VerwerkteMetingFormat"));
}
else if (dataRow[celwaarde].GetType().Equals(Type.GetType("System.Int16")))
{
Decimal getal = Convert.ToDecimal(dataRow[celwaarde]);
cell.Text = getal.ToString(MSBNZBLL.ParameterString.
SysteemParameters.GetParameterAsString("VerwerkteMetingFormat"));
}
else if (dataRow[celwaarde].GetType().Equals(Type.GetType("System.Int64")))
{
Decimal getal = Convert.ToDecimal(dataRow[celwaarde]);
cell.Text = getal.ToString(MSBNZBLL.ParameterString.
SysteemParameters.GetParameterAsString("VerwerkteMetingFormat"));
}
break;
}
}
}
}
}
return row;
}
In Word you can only store 2 bytes. That is why I use Writer.
|
|
|
|
|
Hi
I am developing an windows service that sends email notifications to all not activated members and not published users. I tested my email notifications with a sample windows application but the same notifications are failing in my service. But I put all of the dlls in the same directory as my service exe file.
Here is the piece that fails:
SMPTServer = this.gs.SMTPServer;
if (userEmail != "" && userEmail != null)
{
//Send Email Notification
doXtop.Framework.Messaging.Message msg = new doXtop.Framework.Messaging.Message(); -- it fails here, but this works with my windows test application.
}
The service logged with "Object reference not set to an instance of an object."
Can any give me ideas, how can I solve this.
modified on Wednesday, March 18, 2009 12:47 PM
|
|
|
|
|
You might get the NUll reference because you first check if userEmail = ""
It is more wise to create the next IF
if (null != userEmail && !userEmail.Equals(String.Empty))
|
|
|
|
|
Hi
I checked it, it was not problem in the line of code that I posted but its the problem with
doXtop.Framework.Messaging.Message msg = new doXtop.Framework.Messaging.Message();
This is strange. For me the following line of code is working but the above one is not working:
doXtop.Framework.Messaging.Message.SendEmail("info@doXtop.com", userEmail, subject, message, SMTPServer);
|
|
|
|
|
can/will you show the code of the messaging class?
|
|
|
|
|
Here is the code of my messaging class:
public class Message : IDisposable
{
public Hashtable HtEmails;
public HttpContext Context;
public bool ThreadExecution = false;
public string From;
public string Subject;
public string SmtpClient;
public string Body;
public string EmailProvider;
public string Username;
public string FullName;
public string ActivationMessage;
public Guid UserId;
public GlobalSettings gs;
public Uri Url;
public string ApplicationPath;
public enum Box
{
Inbox,
Outbox
}
DataAccess _da;
DataSource _ds;
public Message()
{
_da = new DataAccess();
_ds = new DataSource(_da);
ConfigurationProvider cp = new ConfigurationProvider();
gs = cp.GlobalSettings;
}
public bool InsertMessage(string from, string to, string subject, string body, string senderIPAddress)
{
try
{
SqlParameter[] _params = {
new SqlParameter("@MessageId", Guid.NewGuid()),
new SqlParameter("@From", from),
new SqlParameter("@To", to),
new SqlParameter("@Subject", subject),
new SqlParameter("@Body", body),
new SqlParameter("@SenderIPAddress", senderIPAddress)
};
_ds.ExecuteNonQueryProcedureProxy("InsertMessage", _params);
return true;
}
catch (Exception e)
{
EventLog.WriteEntry("WideDocs", e.ToString(), EventLogEntryType.Error);
return false;
}
}
}
|
|
|
|
|
I believe your problem is this:
public Hashtable HtEmails;
public HttpContext Context;
public bool ThreadExecution = false;
public string From;
public string Subject;
public string SmtpClient;
public string Body;
public string EmailProvider;
public string Username;
public string FullName;
public string ActivationMessage;
public Guid UserId;
public GlobalSettings gs;
public Uri Url;
public string ApplicationPath;
they are mostly null. Havent you forget the { get; set; } to use them as properties?
You do not use any of these publics in your class and you cannot set them from outside.
In Word you can only store 2 bytes. That is why I use Writer.
|
|
|
|
|
Hi All,
I have a mysql database. I have a web portal in php where users can update personal information which is added and stored in the database. Im building another web app in asp .net which will feed from the same database.
Is there anyway of 'listening' for when updates occur in the database efficently from my asp .net web app?
Im not sure what the best approach is.
Any suggestions much appreciated.
Thanks
Mike
|
|
|
|
|
hardboy111 wrote: Is there anyway of 'listening' for when updates occur in the database efficently from my asp .net web app?
As both the site are sharing the same database then why you are trying to listing? If there is any update in the database from PHP sites, when user refresh or reload the page in ASP.NET he will get the updated data.
Any specific reason to do that?
cheers,
Abhijit
CodeProject MVP
|
|
|
|
|
hardboy111 wrote: Is there anyway of 'listening' for when updates
what do you mean by 'listening'. The very nature of web application does not allow you to listen to events on the server, or does it.
One way to try is, since they are sharing the same database, in your asp.net you may want to use AJAX to check for updated periodically. This will be small and quick bursts of status checks. When you detect a change, hen you refresh your asp.net pages to fetch updated data.
Yusuf
Oh didn't you notice, analogous to square roots, they recently introduced rectangular, circular, and diamond roots to determine the size of the corresponding shapes when given the area. Luc Pattyn[^]
|
|
|
|
|
im using a COMET approach. Hence if a update occurs I want to be able to push the update down to the web browser without any request from the client.
Polling isnt what I want to do.
|
|
|
|
|
1) does webparts use sql server 2008 database??? with visual studio 2008?
2) if i use webparts then will i have to face some browser compatibility issues??
Government Dyal Singh College Lahore.
|
|
|
|
|
Ans 1 .. No You can use any Database you want.
Ans 2. Webparts in Sharepoint runs best in IE. But you can create web parts that may run in other browsers too. Thats not a problem
|
|
|
|
|
Hi All
Please help, here us the scenario.
I get Source and Source code from the database.
I assign Source to the Text property of the DropDownlist and I assign SourceCode to the Value property of the same DropDownList.
What I want to do is that when you select an item from the DropDownlist, I want take the Value for that Item and do some calculations and keep the selected item shown on the dropDownList.
The problem is that..if the selected item has something eg 2 for the Value the application works fine, but if the Value property for that item in null the dropdown display the first item in the list.
It should display the selected item..it only do this if there is something in the value property.
Here is my code, that populates the dropdownlis.
drpDepot.DataSource = ds;
drpDepot.DataTextField = "SourceName";
drpDepot.DataValueField = "SourceCode";
drpDepot.DataBind();
drpDepot.Items.Insert(0, new ListItem(string.Empty, string.Empty));
Please help, I don’t know what is the problem. Please help.
Thank you in advanced
MP
|
|
|
|
|
khuzwayom wrote: What I want to do is that when you select an item from the DropDownlist, I want take the Value for that Item and do some calculations and keep the selected item shown on the dropDownList.
Please put the code for this section.
cheers,
Abhijit
CodeProject MVP
|
|
|
|
|
Hi
Thanx for the reply. Here is my code
_kilometers = Convert.ToDouble(txtKM.Text);
_value = drpDepot.SelectedValue.ToString().Trim();
if (_value != "")
{
_value4 = double.Parse(_value);
_transportCost = _kilometers * _value4;
lblMessage.Text = "Estimated Transport Cost is: £ " + _transportCost.ToString();
}
I suppose after finishing executing it should keep the Item selected displayed...
MP
|
|
|
|
|
khuzwayom wrote: _kilometers = Convert.ToDouble(txtKM.Text);
_value = drpDepot.SelectedValue.ToString().Trim();
if (_value != "")
{
_value4 = double.Parse(_value);
_transportCost = _kilometers * _value4;
lblMessage.Text = "Estimated Transport Cost is: £ " + _transportCost.ToString();
}
What ever you have to done in the else put.
else
{
}
But still i am not able to understand where did you written the code means in which event you are loading the data and checking the value.
cheers,
Abhijit
CodeProject MVP
|
|
|
|