|
After logging out of my web application I do not want the user to be able to get back into it simply by clicking the browser Back button.
After doing some reading I don't think javascript will allow you to clear browser cache. Do I have to prevent all my asp pages from being cached? On commercial sites it seems that caching is on because the Back button does work. However, after logging out and hitting the Back button an expired page is displayed. How do they do this?
|
|
|
|
|
|
Place this on every page for which you want the back shouldnt be enabled :
function disableBack(){window.history.forward();}
disableBack();
window.onload=disableBack;
window.onpageshow=function(evt){if(evt.persisted)disableBack();}
window.onunload=function(){void(0);}
This is tested on MSIE, FireFox, Safari and Opera.
|
|
|
|
|
Does this mean when you have a logout feature you cannot use the browser cache?
|
|
|
|
|
Hi,
I am using ultrawebgrid in my pages. I am specifying the EditorControl by setting EditorControlID in the InitializeLayout event of the grid. This works fine if I don't have paging or if I am not rebinding the grid. When I enable the paging, the EditorControl works fine in the first page. But when we move to the next page, the EditorControl get's lost. The same is the case when I rebind the grid (as I did in paging). I am giving you the sample code below. Can anyone please help me in resolving this?
protected void Page_Load(object sender, EventArgs e)
{
if (!IsPostBack)
{
InitializePage();
}
}
private void InitializePage()
{
PopulateReportingPeriodTasksGrid();
Infragistics.WebUI.UltraWebGrid.UltraWebGrid comboGrid = (Infragistics.WebUI.UltraWebGrid.UltraWebGrid)StatusCombo.Controls[0];
comboGrid.DisplayLayout.AllowAddNewDefault = Infragistics.WebUI.UltraWebGrid.AllowAddNew.Yes;
comboGrid.DisplayLayout.AllowUpdateDefault = Infragistics.WebUI.UltraWebGrid.AllowUpdate.Yes;
}
private void PopulateReportingPeriodTasksGrid()
{
DataSet ds = new DataSet();
ds.Clear();
ds = DataService.ListReportingPeriodTask(UserIdentity, (int)TaskStatus.Status.Open);
if (ds != null)
{
ReportingPeriodTasksGrid.DataSource = ds.Tables[0].DefaultView;
ReportingPeriodTasksGrid.DataBind();
}
}
protected void ReportingPeriodTasksGrid_InitializeLayout(object sender, Infragistics.WebUI.UltraWebGrid.LayoutEventArgs e)
{
e.Layout.Bands[0].Columns.FromKey("TaskStatus").Header.Caption = "Status";
e.Layout.Bands[0].Columns.FromKey("TaskStatus").Type = Infragistics.WebUI.UltraWebGrid.ColumnType.Custom;
e.Layout.Bands[0].Columns.FromKey("TaskStatus").EditorControlID = "StatusCombo";
e.Layout.Bands[0].Columns.FromKey("TaskStatus").AllowUpdate = Infragistics.WebUI.UltraWebGrid.AllowUpdate.Yes;
e.Layout.Pager.AllowPaging = true;
e.Layout.Pager.PageSize = 25;
}
protected void ReportingPeriodTasksGrid_PageIndexChanged(object sender, Infragistics.WebUI.UltraWebGrid.PageEventArgs e)
{
this.ReportingPeriodTasksGrid.DisplayLayout.Pager.CurrentPageIndex = e.NewPageIndex;
PopulateReportingPeriodTasksGrid();
}
This is one scenario as I explained above...in case page index changed, I am calling the PopulateReportingPeriodTasksGrid() function again and that's when the EditorControl stops working. I've another page, where I am not using "paging", but doing the same as I am doing in the PopulateReportingPeriodTasksGrid procedure. Even in that case, the EditorControl will not work.
Thanks,
Kala
|
|
|
|
|
I think it is better to write this in Infragistics Forum as you will get more people regarding this.
I think the problem is because of not handling the Viewstate of the control properly. check yourself if you are missing something.
You may try removing the line :
PopulateReportingPeriodTasksGrid();
from ReportingPeriodTasksGrid_PageIndexChanged to see what happens then.
|
|
|
|
|
Hi Abhishek,
ThanQ!
I've posted in Infragistics forums also. I am trying to see if someone here faced this kind of problem. We need to bind the grid in PageIndexChanged event. Otherwise, paging won't work.
-Kala
|
|
|
|
|
Have you check removing the line which repopulates the data again.
Also try to do another this
In page_Load write
if (!IsPostBack)
{
InitializePage();
}
PopulateReportingPeriodTasksGrid();
}
and
protected void ReportingPeriodTasksGrid_PageIndexChanged(object sender, Infragistics.WebUI.UltraWebGrid.PageEventArgs e)
{
this.ReportingPeriodTasksGrid.DisplayLayout.Pager.CurrentPageIndex = e.NewPageIndex;
}
I think this might be the problem, you are setting the CurrentPageIndex before the data being bound to the control. I am curious if this is the problem with you??
|
|
|
|
|
This change didn't fix it. I see that there is a javascript error though - "'null' is null or not an object".
As said in my initial post, it's not just with paging, whenever I had to rebind the grid, this problem occurs. Looks like the fact that there is an Editor Control is getting lost ( due to viewstate issue or some other problem). I am still trying to debug the same!
Thanks,
Kala
|
|
|
|
|
Anyone? Any thoughts?
In fact, it looks like it's happening on Postback. Am I missing something in restoring the state or something like that? Can you please test the same in a sample application? I tried setting the postback properties to true for the grid but it didn't work!
Thanks,
Kala
|
|
|
|
|
Hi All,
I am trying to create Enum Dynamically.
When I try to Save dll It gives me error - "Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))" I am also writing code snippet :-
AppDomain currentDomain = AppDomain.CurrentDomain;
AssemblyName aName = new AssemblyName("TempAssembly");
AssemblyBuilder ab = currentDomain.DefineDynamicAssembly(aName, AssemblyBuilderAccess.RunAndSave);
ModuleBuilder mb = ab.DefineDynamicModule(aName.Name, aName.Name + ".dll");
EnumBuilder eb = mb.DefineEnum("Elevation", TypeAttributes.Public, typeof(int));
eb.DefineLiteral("Low", 0);
eb.DefineLiteral("High", 1);
Type finished = eb.CreateType();
ab.Save(aName.Name + ".dll");
I got error at last line. I am working on Vista Premium.
I gave permissions to Network Service User but still not solved.
Please help me.
your help is appreciated.
Regards,
Sdhimann
|
|
|
|
|
I am not getting the point of creating a dynamic enum in ASP.NET.
AFAIK, ab.Save() will save the files to AppDomain.CurrentDomain.BaseDirectory . What value are you getting in AppDomain.CurrentDomain.BaseDirectory ? If the path you get is outside the website area, ASP.NET can't write to there.
|
|
|
|
|
Navaneeth,
I have already answered him last night about the problem. I dont know why he is putting the same question again and again in the forum rather than replying the last replies.
|
|
|
|
|
Hi Navaneeth
I want to use Enum in Web parts to show DropDown.
Web parts use only Enum to bind Dropdown.
is there ant other way to solve this problem ?
thanks
|
|
|
|
|
$unil Dhiman wrote: is there ant other way to solve this problem ?
May be. But you haven't answered to my questions which I asked on my last post.
|
|
|
|
|
Hi Navaneeth
Sorry !!!
I got busy in an urgent task at that time.
|
|
|
|
|
If this code is all you are trying to do, then you are wasting your time. Just create the Enum class for you enumerator.
On the other hand if this is a test for more complex process you should discuss this instead. For example, building enumerators from the database is a matter of Googling Emitting Enumerators using T4 . Then learn how to use T4 to dynamically build your classes inline with your code.
|
|
|
|
|
Hi Michael,
Thanks for reply.
I tried to Inherite "Enum" class. but it is giving an error message -
"cannot derive from special class 'System.Enum'"
Please help me how to create Enum Dynamically.
Regards,
Sdhimann
|
|
|
|
|
|
Hi Everyone,
I was curious if it's possible to grab the HTML that a client would receive after the server processes a bit of code. I'm building a web app that will need to send an e-mail notification to the end user. I've already created the dynamic code and display the confirmation on the screen, but what I would like to do is something like this:
MailMessage.Body = Confirmation_div.InnerHtml.ToString();
This way, I can simply email all of the items without having to rebuild the message body html. This bit of code gives me an error indicating that the server can't grab the innerHTML because the div element isn't using any literal controls. Is there a way to convert all of the dynamic controls (after the values have been designated) to literal controls, or somehow grabbing the HTML equilavent that will be sent to the client during the PAGE_PreRender or something?
Thanks!
Knowledge is not power, however, the acquisition and appropriate application of knowledge can make you a very powerful individual.
|
|
|
|
|
Every server control comes with a RenderControl() method which render the control and it's child controls to the specified TextWriter .
Trick here is to make your div run at server. Add a runat=server attribute to the Confirmation_div . Here is a generic method to get the rendered output of any control.
string GetRenderedOutput<T>(T control) where T : Control
{
StringBuilder builder = new StringBuilder();
using (StringWriter sWriter = new StringWriter(builder))
using (Html32TextWriter writer = new Html32TextWriter(sWriter))
{
control.RenderControl(writer);
}
return builder.ToString();
} Use it like
MailMessage.Body = GetRenderedOutput(Confirmation_div); OR
MailMessage.Body = GetRenderedOutput<HtmlGenericControl>(Confirmation_div);
|
|
|
|
|
Hi Navaneeth,
Thanks! I do remember seeing the RenderControl in the intellisense, but it never dawned on me to look into that method! I thought it would be "ClientOutput" or something like that.
I did have a quick question, though. Can you tell me what this line is saying?
string GetRenderedOutput<T>(T control) where T : Control
I understand Where T is inherenting from the Control class , but I've never seen <t>(T Control) before.
Thanks Again!
Knowledge is not power, however, the acquisition and appropriate application of knowledge can make you a very powerful individual.
modified on Monday, September 28, 2009 12:22 PM
|
|
|
|
|
T represents a Generic Type here. Means you can assign any value to T type that inherits Control.
If you write
where T : class
It would take any classes.
I suggest to read the basic books on Generics to clear it more.
|
|
|
|
|
T is a generic type and where T : Control is a constraint. It means T can be of any type that derives from Control . When you write GetRenderedOutput(yourDiv); , compiler will infer the type from the type of yourDiv . Writing GetRenderedOutput<HtmlGenericControl>(yourDiv); is more explicit and it will only take a type of HtmlGenericControl .
|
|
|
|
|
Oh, so then you could write a method to say, format or parse strings, Dictonaries<>, Lists, ect and using a generic, pass the method anything and let it figure out what it is?
bool myMethod<T>(T Object) Where T : Object {}
I'm a self-taught programmer and I've read the whole way through Head First C# (which I really enjoyed and learned a lot), but I don't recall seeing anything about generics....Or if I did, obviously it didn't sink in. I'll have to go back and review that tonight.
Thank's again for all your help!
Knowledge is not power, however, the acquisition and appropriate application of knowledge can make you a very powerful individual.
|
|
|
|