473,385 Members | 2,210 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

Refreshing client browsers (java script from asp.net code)

I have a page called CustomerSlides.aspx which contains an iframe(with the
source Lookupage.aspx). The iframe page will look continuously in the
database to see if a value has changed: if it is true it will run a java
script dynamically to update the parent page CustomerSlides.aspx.cs.
The value in the Database is changed from another aspx page så all the
changes made in this page will be updated in CustomerSlides.aspx.
I used the code below and it is working as long as it is only one client
looking at CustomerSlides.aspx. If more than one client are looking at the
same page from diffrent browsers(computers) no updates are done. Then have to
refresh manually. I wonder why it is working for one client and not for the
other? Is there any solution? Any help is highly appreciated.
See my code below:
Code behind for(CustomerSlides.aspx.cs):

public class CustomerSlides : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Label Message;
protected System.Web.UI.HtmlControls.HtmlGenericControl mainIframe;

public string fullPath;

private void Page_Load(object sender, System.EventArgs e)
{

//Get the logged on administrator's email, retrieved from
"signincustomer.aspx.cs"(Will be used in the next step)
// string adminEmail = Convert.ToString(Session["senderAdmin"]);
string adminEmail = "te**@test.se";

//Retrieve the fullPath to the slide to be shown

// Create Instance of Connection and Command Object
SqlConnection myConnection = new
SqlConnection(ConfigurationSettings.AppSettings["connectionString"]);
// SqlCommand myCommand = new
SqlCommand("Portal_GetSlideFullPathFlag2", myConnection);
SqlCommand myCommand = new SqlCommand("SELECT DISTINCT
FullPath FROM TTflag2 WHERE AdminEmail = @AdminEmail ", myConnection);

// Mark the Command as a SPROC
// myCommand.CommandType = CommandType.StoredProcedure;

// Add Parameters to SPROC
SqlParameter parameterAdminEmail = new
SqlParameter("@AdminEmail", SqlDbType.NVarChar, 50);
parameterAdminEmail.Value = adminEmail;
myCommand.Parameters.Add(parameterAdminEmail);
try
{
// Execute the command
myConnection.Open();
SqlDataReader dr =
myCommand.ExecuteReader(CommandBehavior.CloseConne ction);

dr.Read();
fullPath = dr.GetString(0);

dr.Close();
}
catch (Exception ex)
{
Message.Text = ex.Message + " " + ex.StackTrace;
}

if ((fullPath != string.Empty) & (fullPath !=
null))
{
//Find the mainIframe control and add a source attribute
to it
HtmlControl mainIframe =
(HtmlControl)this.FindControl("menuForm").FindCont rol("mainIframe");
mainIframe.Attributes["src"] = fullPath;

}
else
{
HtmlControl mainIframe =
(HtmlControl)this.FindControl("menuForm").FindCont rol("mainIframe");
mainIframe.Attributes["src"] = "MainCustomer.aspx";
}
}

//-------------------------------------------------------------------------------------------------------------------------------------------------------
Code Behind for (LookupPage.aspx.cs):

public class LookupPage : System.Web.UI.Page
{
protected System.Web.UI.WebControls.Label Message;
public string adminEmail;
private void Page_Load(object sender, System.EventArgs e)
{

//Get the logged on administrator's email(Will be used in the
next step)
// string adminEmail = Convert.ToString(Session["adminEmail"]);
string adminEmail = "te**@test.se";
//************************************************** *******************
//
// This gets the count of the slides in Table TTflag,
// This tell us if we need to refresh CustomerSlides.aspx.
//

//************************************************** *******************

// Create Instance of Connection and Command Object
SqlConnection myConnection = new
SqlConnection(ConfigurationSettings.AppSettings["connectionString"]);
SqlCommand myCommand = new
SqlCommand("Portal_GetSlideInsertFlag2", myConnection);

// Mark the Command as a SPROC
myCommand.CommandType = CommandType.StoredProcedure;

// Add Parameters to SPROC
SqlParameter parameterAdminEmail = new
SqlParameter("@AdminEmail", SqlDbType.NVarChar, 50);
parameterAdminEmail.Value = adminEmail;
myCommand.Parameters.Add(parameterAdminEmail);
// myCommand.CommandTimeout = 300;

try
{
// Execute the command
myConnection.Open();

//Get the slide which has been clicked by the
administrator
//from database table TTflag
int myInsert = Convert.ToInt32(myCommand.ExecuteScalar());
ViewState["myInsert"]= myInsert;
}
catch(Exception ex)
{
Message.Text = ex.Message + " " + ex.StackTrace;
}

finally
{
//Close connection
if(myConnection.State != ConnectionState.Closed)
myConnection.Close();
}

//Control if there is a slide in database table TTflag
(inserted by the logged on administrator)
if(Convert.ToInt32(ViewState["myInsert"]) > 1)
{
//Refreshes the actual page
//Add the script to declare the
function
StringBuilder sb = new
StringBuilder("");
sb.Append("<script language =
javascript>");
sb.Append("{");

sb.Append("window.parent.location.reload();");
sb.Append("}");
//Close script
sb.Append("<");
sb.Append("/");
sb.Append("script>");

//Register the script (names
are CASE-SENSITIVE)
// if
(!IsClientScriptBlockRegistered("window.parent.loc ation.reload();"))

RegisterStartupScript("ReloadScript", sb.ToString());

//Delete the slide (inserted by the logged on
administrator) from TTflag
PresentationDB deleteSlideInsert = new PresentationDB();
deleteSlideInsert.DeleteSlideInsertFlag2(adminEmai l);
}

}
Jul 21 '05 #1
1 1776
Not wrong can happen, just to prevent double opening
Jul 21 '05 #2

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

Similar topics

1
by: viktor9990 | last post by:
I have a page called CustomerSlides.aspx which contains an iframe(with the source Lookupage.aspx). The iframe page will look continuously in the database to see if a value has changed: if it is...
3
by: John Ortt | last post by:
I appologise for reposting this but I have been trying to find a solution all week with no avail and I was hoping a repost might help somebody more knowledgable than myself to spot the message... ...
0
by: viktor9990 | last post by:
I have a page called CustomerSlides.aspx which contains an iframe(with the source Lookupage.aspx). The iframe page will look continuously in the database to see if a value has changed: if it is...
10
by: Nathan Sokalski | last post by:
One thing that I have often needed to do that I have been unable to find a way to do is refresh the page (basically do the same thing as pressing the browser's Refresh button). I know how to do...
1
by: viktor9990 | last post by:
I have a page called CustomerSlides.aspx which contains an iframe(with the source Lookupage.aspx). The iframe page will look continuously in the database to see if a value has changed: if it is...
5
by: Ankur | last post by:
Hi Folks, I am new for this group. I want to clarify one thing what's a basic difference between Client Side Java Script and Server Side Java Script. how we can differentiate it. Why we called...
6
by: bnashenas1984 | last post by:
Here you can see the script I found in google to refresh a page without hearing any click sound which is usual to hear when a link is clicked or a page is refreshed. <script...
2
by: stevemtno | last post by:
I've got a problem with a web page I'm working on. I have 4 modules - one of them has 2 tabs, two of them have 4 tabs. When the user clicks on the tabs, the content below them changes. However, when...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.