yes ofcourse, i've just created a dummy page, take out the javascript portion and CSS portion, dont forget to copy the two div elements. you need to copy all these things to all the pages you want to disable. and in code behind you just call the method as
im calling based on your condition.
Ashutosh Pathak
Blog: http://catchcode.blogspot.com Please mark it as answer if it helps, as clicking on the button can save time of others :)
MCP,MCAD,MCSD,MCTS
in such cases you need to store the values or set a flag value in your database for the day, if the flag value is up for that user in your database, then in page load you will disable the page. to be precise you also need to create a database schema for
user wise day wise flag entry,.
Ashutosh Pathak
Blog: http://catchcode.blogspot.com Please mark it as answer if it helps, as clicking on the button can save time of others :)
MCP,MCAD,MCSD,MCTS
I already have the list of holidays in my database. But the point is that I don't know how to use them at this moment, as a condition to disable the page...?
I fetch the holidays through stored procedures. But here I don't know how to code for the condition?
its pretty simple, just check the current day using datetime.now. later iterate with the list of holidays that you got in a dataset or datareader to search the entry of current date, if you get any date like such, call the Popup method and break the code
from there.
Ashutosh Pathak
Blog: http://catchcode.blogspot.com Please mark it as answer if it helps, as clicking on the button can save time of others :)
MCP,MCAD,MCSD,MCTS
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Threading;
using System.Data;
public partial class SomeJunk_DisablePage_DisablePage : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack) // here you can write your code to check user visits to show or hide the script
{
DateTime _dt = DateTime.Now;
DataSet _dset = LoadDataSet();
foreach (DataRow _dr in _dset.Tables[0].Rows)
{
DateTime dtRow = Convert.ToDateTime(_dr["Holiday"].ToString());
if (dtRow.Month == _dt.Month && dtRow.Day == _dt.Day && dtRow.Year == _dt.Year)
{
ClientScript.RegisterStartupScript(this.GetType(), "s", " Popup('Hello');", true);
}
}
}
}
public DataSet LoadDataSet()
{
DataSet _dset = new DataSet();
_dset.Tables.Add(new DataTable());
_dset.Tables[0].Columns.Add("Holiday", typeof(DateTime));
for (int i = 0; i < 6; i++)
{
DataRow _dr = _dset.Tables[0].NewRow();
_dr["Holiday"] = DateTime.Now.AddDays(i);
_dset.Tables[0].Rows.Add(_dr);
}
return _dset;
}
}
Ashutosh Pathak
Blog: http://catchcode.blogspot.com Please mark it as answer if it helps, as clicking on the button can save time of others :)
MCP,MCAD,MCSD,MCTS
Marked as answer by coolpal9 on Apr 10, 2012 12:30 PM
Ashutosh Pat...
Contributor
5737 Points
1105 Posts
Re: How to keep a page disabled for a particular user?
Apr 10, 2012 10:39 AM|LINK
yes ofcourse, i've just created a dummy page, take out the javascript portion and CSS portion, dont forget to copy the two div elements. you need to copy all these things to all the pages you want to disable. and in code behind you just call the method as im calling based on your condition.
Blog: http://catchcode.blogspot.com
Please mark it as answer if it helps, as clicking on the button can save time of others :)
MCP,MCAD,MCSD,MCTS
coolpal9
Member
156 Points
520 Posts
Re: How to keep a page disabled for a particular user?
Apr 10, 2012 10:55 AM|LINK
Thanks a lot! Its working! i ran code without checking conditions.
How shall I check for the condition? I am not getting it. I want the page to be disabled:
1. when the page has been already visited for the day and "submit" button has been clicked
2. on certain days (like weekends) it should be disabled
Ashutosh Pat...
Contributor
5737 Points
1105 Posts
Re: How to keep a page disabled for a particular user?
Apr 10, 2012 11:19 AM|LINK
in such cases you need to store the values or set a flag value in your database for the day, if the flag value is up for that user in your database, then in page load you will disable the page. to be precise you also need to create a database schema for user wise day wise flag entry,.
Blog: http://catchcode.blogspot.com
Please mark it as answer if it helps, as clicking on the button can save time of others :)
MCP,MCAD,MCSD,MCTS
coolpal9
Member
156 Points
520 Posts
Re: How to keep a page disabled for a particular user?
Apr 10, 2012 11:41 AM|LINK
I already have the list of holidays in my database. But the point is that I don't know how to use them at this moment, as a condition to disable the page...?
I fetch the holidays through stored procedures. But here I don't know how to code for the condition?
Ashutosh Pat...
Contributor
5737 Points
1105 Posts
Re: How to keep a page disabled for a particular user?
Apr 10, 2012 11:55 AM|LINK
its pretty simple, just check the current day using datetime.now. later iterate with the list of holidays that you got in a dataset or datareader to search the entry of current date, if you get any date like such, call the Popup method and break the code from there.
Blog: http://catchcode.blogspot.com
Please mark it as answer if it helps, as clicking on the button can save time of others :)
MCP,MCAD,MCSD,MCTS
coolpal9
Member
156 Points
520 Posts
Re: How to keep a page disabled for a particular user?
Apr 10, 2012 12:01 PM|LINK
Yes I have the holidays in a DataSet.
Do you mean that by showing:
DataSet ds;
if(ds.System.DateTime.Now)
{}
something like this the condition will be met?
Can you pl help me out in the code?
Ashutosh Pat...
Contributor
5737 Points
1105 Posts
Re: How to keep a page disabled for a particular user?
Apr 10, 2012 12:21 PM|LINK
i think you can use code like below:
using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; using System.Threading; using System.Data; public partial class SomeJunk_DisablePage_DisablePage : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack) // here you can write your code to check user visits to show or hide the script { DateTime _dt = DateTime.Now; DataSet _dset = LoadDataSet(); foreach (DataRow _dr in _dset.Tables[0].Rows) { DateTime dtRow = Convert.ToDateTime(_dr["Holiday"].ToString()); if (dtRow.Month == _dt.Month && dtRow.Day == _dt.Day && dtRow.Year == _dt.Year) { ClientScript.RegisterStartupScript(this.GetType(), "s", " Popup('Hello');", true); } } } } public DataSet LoadDataSet() { DataSet _dset = new DataSet(); _dset.Tables.Add(new DataTable()); _dset.Tables[0].Columns.Add("Holiday", typeof(DateTime)); for (int i = 0; i < 6; i++) { DataRow _dr = _dset.Tables[0].NewRow(); _dr["Holiday"] = DateTime.Now.AddDays(i); _dset.Tables[0].Rows.Add(_dr); } return _dset; } }Blog: http://catchcode.blogspot.com
Please mark it as answer if it helps, as clicking on the button can save time of others :)
MCP,MCAD,MCSD,MCTS
coolpal9
Member
156 Points
520 Posts
Re: How to keep a page disabled for a particular user?
Apr 10, 2012 12:31 PM|LINK
Thanks!
coolpal9
Member
156 Points
520 Posts
Re: How to keep a page disabled for a particular user?
Apr 11, 2012 05:08 AM|LINK
Got it run!
</div>coolpal9
Member
156 Points
520 Posts
Re: How to keep a page disabled for a particular user?
Apr 11, 2012 06:24 AM|LINK
@Ashutosh Pathak
The code works but only once. When I execute it again for checking conditions, it again restricts me from viewing...
How to solve this problem?