|
check this link
http://www.codecomments.com/ASP_.NET_Caching/message670221.html
|
|
|
|
|
hi Albanian
I did check the link. My Page_Unload event is not invoked at all. Is their anyway I can invoke that.
Using javascript I am able to catch the browser closing but I need some way to do without that.
|
|
|
|
|
chinky singh wrote: Is their anyway I can catch the browser closing event in asp.net rather than javascript?
No. The server never knows when the browser window closes, so there is no server side event for that.
If you don't mind waiting for the session to time out, you can catch that event.
However, there is no completely safe method to catch a user going away. If the application thread is recycled, some sessions might be removed without timing out. You will be able to catch almost every user going away, but you should have some code to take care of the occasional one that you can't.
---
b { font-weight: normal; }
|
|
|
|
|
I will ask the question with a 2 step introduction... Please help me.
Step 1: I write an unmanaged DLL in C++. Here is the exported function:
SAMPLEDLL_API void StringAsOUT_AllocatedInDll( char ** szParam )<br />
{<br />
*szParam = new char [ 128 ];<br />
strcpy( *szParam, "Please free my memory after using me!" );<br />
}
Step 2: I write a C# managed EXE to use this DLL
class Imports<br />
{<br />
[DllImport("SampleDLL.dll")]<br />
public static extern void StringAsOUT_AllocatedInDll( ref int szParam );<br />
...<br />
}
...<br />
Imports impObj = new Imports();<br />
int iAddressOfANSIString = 0;<br />
impObj.StringAsOUT_AllocatedInDll( ref iAddressOfANSIString );<br />
string strOUTPUTFromUnmanagedDll = Marshal.PtrToStringAnsi( ( IntPtr ) iAddressOfANSIString );<br />
Console.WriteLine( "Value of strOUTPUTFromUnmanagedDll = {0}", strOUTPUTFromUnmanagedDll );<br />
...
Question: The code works. It does give console output "Value of strOUTPUTFromUnmanagedDll = Please free my memory after using me!"
But isn't there a memory leak? How do I free the memory allocated by new[] inside the unmanaged DLL? All the Marshal class helps artciles always refer to how to free an unmanaged memory block when it is allocated from .NET code. But here it is allocated by unamanaged code. If anybody can please help me with this, I will be grateful.
Thank you!
|
|
|
|
|
http://www.csharpfriends.com/Spec/index.aspx?specID=25.8.htm
|
|
|
|
|
Thanks Albanian. But that really does not answer my question - as you see the article describes how to free the memory only if it was allocated from the C# code.
Like this: You in C#: you allocate some memory in unmanaged heap, and then you free it anfter using it. That is what the article shows.
But my situation is different: I am calling an unmanaged DLL that allocates the memory and returns the pointer. I use it from C#. There is no corresponding call back to the unmanaged DLL that will free the memory. I will have to free it myself from C# after using it.
As I did not allocate it, I don't have the HGlobal Handle or anything - all I have is the address returned. No Marshal class function is helping me out!
Thanks again for seeing my post and replying - I have been waiting for 2 days (i had posted this 2 days ago also) - but nobosy seems to have an answer!
Koushik Biswas
|
|
|
|
|
I mean, simply put, my question becomes: is there a way to call delete[] from C#?
Koushik
|
|
|
|
|
lookup this
http://www.c-sharpcorner.com/Language/PointersInCSharpRVS.asp
|
|
|
|
|
I was trying to do the same for some time.
Eventualy I realized that the best method is to allocate memory in C# and send a referance of the memory array to the C++ mthod\function. You might have a probelm determining the size of the array needed but that is a different story.
Even if you get it to work, it would be very careless doing so.
Gilad.
|
|
|
|
|
Dear all,
Can any one explain me what is the difference between container control and normal control Since both are derived from a Control class I am not able to differenciate them.please help me to find out the given control is container control or not.
Have a nice day.
|
|
|
|
|
Control container is example Panel in which we can set controls such is button,textbox,label,datetimepicker, etc....
Control is single one - example : button
Control is single one - example : label
Control is single one - example : textbox
Control is single one - example : datetimepicker, etc....
|
|
|
|
|
thanks for your reference.
How can I identify that the control is container control or not, at runtime.
Contact him at: hasansheik@hotmail.com
hasansheik@yahoo.co.in
hasansheik@lycos.com
|
|
|
|
|
hasansheik wrote: How can I identify that the control is container control or not, at runtime.
Test the control against System.Windows.Forms.ContainerControl using the is operator:
System.Console.WriteLine(this is System.Windows.Forms.ContainerControl);
System.Console.WriteLine(label1 is System.Windows.Forms.ContainerControl); Where this is the form. The above two lines return true and false , respectively, since Form is derived from ContainerControl , and Label is not.
ContainerControl inherits from ScrollableControl , which you can read about here[^].
Share and enjoy.
Sean
|
|
|
|
|
Dear all,
can any one help me to find out the given control is container control or not.
Warm regards,
S. Mohamed hasan.
Have a nice day.
|
|
|
|
|
Hello i would like to create an excel file from my application that could include chart or images, is there any free component, or any other way to do it without using excel.interop(i want to run it even in a pc without excel installed)
D.M
|
|
|
|
|
Here's what you do:- Create an Excel Workbook with the type of content you want on each page
- Save the Entire Workbook as an HTML Page
- Look at how everything gets save and reproduce it with your project
I've had to do this more than once. Works like a charm.
"we must lose precision to make significant statements about complex systems."
-deKorvin on uncertainty
|
|
|
|
|
ty for ur reply but my output its a litle complicated to outut such way, i pass multi sized lists etc
D.M
|
|
|
|
|
I am using visual Basic .NET 2005
I have the following tables with data
------------------------------------------------------
Courses
=======
Course_Code Title
=========== ==============================
3403 Discrete Mathematics
3456 Calculus
3409 Electronics
3510 Business Research Methods
-------------------------------------------------------
Student
========
Student_ID Name
========== ===============================
6316 ABC
6318 XYZ
6309 CDE
6314 FGH
-------------------------------------------------------
Student_Courses
===============
Student_ID Course_Code
========== ===============================
6316 3403
6316 3409
6316 3456
6309 3456
6309 3510
6318 3403
-------------------------------------------------------
First I want to show all the courses available in a CheckedListBox (Display only the title for the course)
Then I want all those courses in the CheckedListBox to be checked if a particular Student had opted for those courses (retrieved from Student_Courses table)
When saving the data in Student_Courses table I want to save the checked courses
But the problem is how do I bind the CheckedListBox with a data source and get the lookup value (Course_Code) from the CheckedListBox
CheckedListBox does not have any of the DataSource, DisplayMember and ValueMember property
Is there any way around?
Can any other control serve this purppose?
Thank You.
|
|
|
|
|
I created a strong typed CollectionBase collection.
When I bind it to a DataGrid, it displays all the public properties for the class. I only want to display specific class properties. I tried to use the following code and it does not work.
How do you control what fields are displayed in the DataGrid?
private void BindArrayListToGrid()
{
// create some data
dataGrid1.DataSource = myCollection;
DataGridTableStyle ts = new DataGridTableStyle();
ts.MappingName = "ArrayList";
DataGridTextBoxColumn cs = new DataGridTextBoxColumn();
cs.MappingName = "id"; // Public property name
cs.HeaderText = "User ID";
cs.Width = 80;
ts.GridColumnStyles.Add(cs);
cs = new DataGridTextBoxColumn();
cs.MappingName = "name";
cs.HeaderText = "User Name";
cs.Width = 80;
ts.GridColumnStyles.Add(cs);
// Add the custom tablestyle to the DataGrid
this.dataGrid1.TableStyles.Clear();
this.dataGrid1.TableStyles.Add(ts);
}
TC
|
|
|
|
|
I want to open e web from my C# aplication but i need to autentificate with a proxi
how can i do it
|
|
|
|
|
Assuming you're using WebClient and your proxy is using basic authentication, add the
Proxy-Authenticate[^] field to the Headers collection.
string base64 = Convert.ToBase64String(Encoding.ASCII.GetBytes("<username>:<password>"));
webClient.Headers.Add("Proxy-Authenticate", "Basic " + base64);
Or, you can use the NetworkCredential class to do it for you.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
before anyting thanks for your reply and have a happy new year
i was trying to understand what i was asking for and i couldnt understand a sh*t anyway
i either understang anthing of what you answer me
what i was trying to do was a web application that, using forms authentication authenticate users from a db and could even create new users
i wish you could tell me how can i do the first
thanks
|
|
|
|
|
Hi,
I am trying to create an application which receives data from the network (probably a ZIP file) and write the content of network stream to the a LOCAL File... i can receive data and i can echo it out the console as well... i can write a file... but when i open up the file ... it has no content... what am i doing wrong?
here is the code:
private void readFile(int filesize)
{
try
{
FileStream fout = new FileStream(this.m_backupFileName,FileMode.CreateNew,FileAccess.Write);
NetworkStream ns = new NetworkStream(clientSock);
long rby=0;
int totalRecv=0;
//loop until the full bytes have been read
while( rby < filesize )
{
byte[] buff = new byte[1024];
//read from network stream
int i = ns.Read(buff,0,buff.Length);
Console.WriteLine(Encoding.ASCII.GetString(buff));
fout.Write(buff,0,i);
totalRecv += i;
rby = rby+1;
}
//done with reading
fout.Close();
//clientSock number of bytes
Console.WriteLine("Sending Num of Bytes");
clientSock.Send(Encoding.ASCII.GetBytes("DONE " + totalRecv.ToString()));
//get server's response
byte[] buf = new byte[128];
string resp = "";
clientSock.Receive(buf);
resp = Encoding.ASCII.GetString(buf);
if( resp == "OK" )
Console.Write("File Transfer Complete");
else if( resp == "ERROR")
Console.Write("Please Try Again");
}
catch(Exception ex) { Console.WriteLine(ex.ToString());}
}
|
|
|
|
|
I am using a typed dataset to store my data. I use a dataView to pull out what i need. the problem comes up in one case. I have a dataView that does not return what it should.
The DV init is:
<br />
DataView mDv = new DataView(ds.tblData, "(issent = false AND userIDN = " + userID + ") OR pending_draws = true","dataID", DataViewRowState.CurrentRows);<br />
If i run the same parameters in a SQL query it returns the correct rows. any ideas?
|
|
|
|
|
I am using the File.Create method to create a text file. My problem is that when I need to write to that file after it has been created I get the error message "The process cannot access the file "C:\2005 Sim R4 MedAlu Data\TN.txt" because it is being used by another process.".
|
|
|
|