|
is it possible to keep a Dataset in Cache( Page or Application or Fragment) like session
Thanks in advance
-
|
|
|
|
|
One Post is Enough.
Regards,
Satips.
|
|
|
|
|
A session can hold a dataset
hope it works.
regards
|
|
|
|
|
Session ["MySessionVar"] = myDataSet not sufficient for you?
"Now I guess I'll sit back and watch people misinterpret what I just said......"
Christian Graus At The Soapbox
|
|
|
|
|
is it possible to keep a Dataset in Cache( Page or Application or Fragment) like session
Thanks in advance
-
|
|
|
|
|
This Example will help you.
In the following sample a file is read in Application_Start (defined in the Global.asax file) and the content is stored in a DataView object in the application state.
C#
void Application_Start()
{
DataSet ds = new DataSet();
FileStream fs = new FileStream(Server.MapPath("schemadata.xml"),FileMode.Open,FileAccess.Read);
StreamReader reader = new StreamReader(fs);
ds.ReadXml(reader);
fs.Close();
DataView view = new DataView(ds.Tables[0]);
Application["Source"] = view;
}
function Application_Start() : void
{
var ds:DataSet = new DataSet();
var fs:FileStream = new FileStream(Server.MapPath("schemadata.xml"),FileMode.Open,FileAccess.Read);
var reader:StreamReader = new StreamReader(fs);
ds.ReadXml(reader);
fs.Close();
var view:DataView = new DataView(ds.Tables[0]);
Application("Source") = view;
}
Regards,
Satips.
|
|
|
|
|
Hi in my project default page i am using frame set in that 3 html pages i included...,
When run the project it will check login authentication..,
If its correct user...,then in that default page head htmlpage my link buttons will display...,
When i click in that link left side html page sub links will be display...,
if i click any of the sub link then my aspx page will be display in that 3rd html page(right hand side)...,
In this i said suppose the user didnt interact with some what time the forms then session will be end...,so it will transfer to login.aspx page...,
But the login.aspx page is displaying on the right hand side of the frameset..,
But when session will end i need only starting page login.aspx other head html page and left side html page all want to unload
How to do this one plz tell me...,
-- modified at 2:03 Thursday 19th April, 2007
Magi
|
|
|
|
|
.net does not support frame concepts. so you can use this statement
i have test it with framework 2.0
c#
--
if (Session.IsNewSession)
{
Response.Write("top.location='login.aspx';");
}
vb.net
--
If (Session.IsNewSession) then
Response.Write("top.location='login.aspx';")
End If
|
|
|
|
|
Hi,
I wanted a Message Box that has Yes No Cancel where if the user click Yes only it will go to the next statement. Example
If MessageBox = "Yes" Then
'Do something
Else
'Do something
End If
I'd tried using javascript but I don't understand how the javascript can return "Yes" to ASP.net.
|
|
|
|
|
you can store javascript return in hidden type input and check this value at the server.
Regards
Shajeel
|
|
|
|
|
Hi Shajeel,
Actually I wrote a function for it like this
Public Sub MsgBoxYesNo(ByVal Message As String)
System.Web.HttpContext.Current.Response.Write("" & vbCrLf)
System.Web.HttpContext.Current.Response.Write("if(confirm(""" & Message & """)){} else { return false }" & vbCrLf)
System.Web.HttpContext.Current.Response.Write("")
End Sub
Then only I realized when I call this function, I can't return the yes no from the javascript above such as Dim response As String = MsgBoxYesNo("Are you sure you want to delete")
J Liang
|
|
|
|
|
you cannot stop next statement like this, because javascript is executed after all code behind is executed, you have to take two round trips here in which case the better option will be show a simple page with message and yes and no button with proper redirection and not by script.
Regards
Shajeel
|
|
|
|
|
Alright then, thanks for the advice, I shall create a new window for that then.
J Liang
|
|
|
|
|
use btn.attributes.add("onclientclick","function()";) on page load
|
|
|
|
|
Hi,
Just want to confirm something. The onclientclick is something like onclick which I can keep the way it is here? And the function(), it is the javascript function which I embedded it in my HTML? Because when I try that, the message box didn't pops out...
J Liang
|
|
|
|
|
Hey,
Thanks for the code, it's working now, didn't know it was that simple
J Liang
|
|
|
|
|
copy this code in any cs file and access it.
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
///
/// Summary description for MessageBox
///
public class MessageBox
{
public class MessageBox
{
private static Hashtable m_executingPages = new Hashtable();
private MessageBox() { }
public static void Show(string sMessage)
{
// If this is the first time a page has called this method then
if (!m_executingPages.Contains(HttpContext.Current.Handler))
{
// Attempt to cast HttpHandler as a Page.
Page executingPage = HttpContext.Current.Handler as Page;
if (executingPage != null)
{
// Create a Queue to hold one or more messages.
Queue messageQueue = new Queue();
// Add our message to the Queue
messageQueue.Enqueue(sMessage);
// Add our message queue to the hash table. Use our page reference
// (IHttpHandler) as the key.
m_executingPages.Add(HttpContext.Current.Handler, messageQueue);
// Wire up Unload event so that we can inject some JavaScript for the alerts.
executingPage.Unload += new EventHandler(ExecutingPage_Unload);
}
}
else
{
// If were here then the method has allready been called from the executing Page.
// We have allready created a message queue and stored a reference to it in our hastable.
Queue queue = (Queue)m_executingPages[HttpContext.Current.Handler];
// Add our message to the Queue
queue.Enqueue(sMessage);
}
}
// Our page has finished rendering so lets output the JavaScript to produce the alert's
private static void ExecutingPage_Unload(object sender, EventArgs e)
{
// Get our message queue from the hashtable
Queue queue = (Queue)m_executingPages[HttpContext.Current.Handler];
if (queue != null)
{
StringBuilder sb = new StringBuilder();
// How many messages have been registered?
int iMsgCount = queue.Count;
// Use StringBuilder to build up our client slide JavaScript.
sb.Append("");
// Loop round registered messages
string sMsg;
while (iMsgCount-- > 0)
{
sMsg = (string)queue.Dequeue();
sMsg = sMsg.Replace("\n", "\\n");
sMsg = sMsg.Replace("\"", "'");
sb.Append(@"alert( """ + sMsg + @""" );");
}
// Close our JS
sb.Append(@"");
// Were done, so remove our page reference from the hashtable
m_executingPages.Remove(HttpContext.Current.Handler);
// Write the JavaScript to the end of the response stream.
HttpContext.Current.Response.Write(sb.ToString());
}
}
}
}
|
|
|
|
|
Hi,
Sorry, ermm...this look a bit complicated for me but thanks really for your response, I shall try to check out how your code work here.
J Liang
|
|
|
|
|
Hi all,
i have one doubt. is it possible to use asp files to asp.net project??
Thanks,
Rahi
If you look at what you do not have in life, you don't have anything,
If you look at what you have in life, you have everything... "
|
|
|
|
|
Yes, you can. You can also just rename them to be asp.net (aspx) and make sure you add the runat="server" attributes. Work the same as when you want to use html in asp.net.
|
|
|
|
|
List<object[]> topics = Database.SerializeQuery();
repeaterTopics.DataSource = topics;
repeaterTopics.DataBind();
I am filling my repeater's datasource with a type List <object[]>.
Normally to access these elements, in C# I would use, for example: topics[0][1].
However since it's in my repeater how do access the individual elements from the aspx page using the repeater syntax?
<div id='topics'>
<asp:Repeater ID="repeaterTopics" runat="server">
<ItemTemplate>
<!--How do I access the List here?? -->
</ItemTemplate>
</asp:Repeater>
</div>
/\ |_ E X E GG
|
|
|
|
|
Hello. Is there any way a custom server control can can programmatically add controls to the parent pages controls collection?
I've tried the following...
protected override void Render(HtmlTextWriter writer)<br />
{<br />
this.Page.Controls.Add(new HtmlGenericControl("div"));<br />
....<br />
}
...but it gives me an error "Collection was modified; enumeration operation may not execute.". I've also tried adding the above code into the OnPreRender and OnInit events but it still gives me an error, this time "The control collection cannot be modified during DataBind, Init, Load, PreRender or Unload phases.".
What I am trying to do is get a server control to add a div tag to the parent page but positioned just after the opening body tag or just before the closing body tag, just so that it's not wrapped in any other elements basically. Something tells me this isn't possible but thought I'd ask you folks before I gave up on this.
|
|
|
|
|
Usualy the reason for this error is that the collection is changed(items added or removed) within the loop.
|
|
|
|
|
I have the followning code in my HTML part. But when I click on Deletw link it deleted the record from gridview as well as from Datasource but it give me following error page
Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.
Exception Details: System.NotSupportedException: Updating is not supported by ObjectDataSource 'ObjectDataSource1' unless the deleteMethod is specified.
Here Is the code
<asp:gridview id="gdAddUser" runat="server" allowsorting="True" autogeneratecolumns="False"
="" datakeynames="UserId" datasourceid="ObjectDataSource1" onrowcommand="gdAddUser_RowCommand" onrowdatabound="gdAddUser_RowDataBound" onrowdeleting="gdAddUser_RowDeleting" width="390px" onselectedindexchanged="gdAddUser_SelectedIndexChanged" autogenerateeditbutton="True">
<columns>
<asp:boundfield datafield="AppName" headertext="Application">
<asp:boundfield datafield="AppRight" headertext="Permissions">
<asp:templatefield headertext="Select">
<itemtemplate>
<asp:linkbutton id="LinkButton1" runat="server"
="" commandargument="<%# Eval("UserId") %>" commandname="Delete">
Delete
protected void gdAddUser_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{
LinkButton l = (LinkButton)e.Row.FindControl("LinkButton1");
l.Attributes.Add("onclick", "javascript:return " +
"confirm('Are you sure you want to delete this record " +
DataBinder.Eval(e.Row.DataItem, "UserId") + "')");
}
}
protected void gdAddUser_RowCommand(object sender, GridViewCommandEventArgs e)
{
if (e.CommandName == "Delete")
{
// get the categoryID of the clicked row
int AppId = Convert.ToInt32(e.CommandArgument);
// Delete the record
DeleteRecordByID(AppId);
// Implement this on your own
}
}
//protected void gdAddUser_RowDeleted(object sender, GridViewDeletedEventArgs e)
//}
protected void gdAddUser_RowDeleting(object sender, GridViewDeleteEventArgs e)
{
int AppId = (int)gdAddUser.DataKeys[e.RowIndex].Value;
DeleteRecordByID(AppId);//implement yourself
}
|
|
|
|
|
Hi Guys
I need help on .NET 2005. K2.NET 2003 have SmartForms templates that work with .NET 2003, but I need to get it working on 2005 since they dont get listed. Does anyone done this before?
Kind Regards
Elizma
-- modified at 14:55 Wednesday 18th April, 2007
|
|
|
|