|
Hi all,
I am pretty new to C#. I would like to log what's going on in my application. i used log4J while programming in java. i saw some open source tools for c# but can anyone please let me know which way is better?
regards,
rnv
|
|
|
|
|
For simple logging, the System.Diagnostics namespace has the Debug and Trace classes, which you might want to look into.
Regards
Senthil
_____________________________
My Blog | My Articles | WinMacro
|
|
|
|
|
|
The problem with the logging block from MS that I know of is that you have to have it installed on the machine you want to run on. So if a customer has your application or a friend, they would have to have EIF installed to do the logging. With log4net you would just need to turn on the logging from the config file (or send them a config file with logging turned on).
Steve Maier, MCSD MCAD
|
|
|
|
|
Hello,
I have TextBox1 and TextBox2, and the tab index is 0 and 1 respectivelly.
Also I have a leave event on TextBox1. So the problem is, when the form containing these two controls opens, it fires the leave event on TextBox1 and sets focus to it as per tab index.
Is there a way to avoid the leave event until you actually leave the control?
Thank you
|
|
|
|
|
|
Hey! I did not get the problem. The event is fired only when it leaves the control.
Jayant D. Kulkarni
Brainbench Certified Software Engineer in C#, ASP.NET, .NET Framework and ADO.NET
|
|
|
|
|
I am creating a website where I populate an html table with rows of data that I acquire from a database. For each record in the database, a new row is created in the table with various controls like dropdownboxes, text inputs, buttons, etc. (some are html controls, some are asp controls). Each control is given a unique ID based on the record number/row in the table (ex. btnUpdate_1, btnUpdate_2, etc.). What I am trying to accomplish is, that if the user clicks the Update button (I don't care if the button is an asp or html control), I want to be able to grab the data they entered or changed in the all the other controls in that same row - the dropdownboxes, text inputs, etc. - so that I can then go and update the database. However, I cannot access these controls on the server-side since they are created dynamically and I've tried using some javascript to get the data, but even then, I can only seem to use the data on the client side & am unable to figure out how to use it on the server-side. I hope all this mumble-jumble makes sense. But here is some example code of how the controls are being created...
protected System.Web.UI.WebControls.PlaceHolder plcQ;
private void Page_Load(object sender, System.EventArgs e)
{
string projPath = @"m:Survey\";
Session["myQConn"] = "Provider=MSDASQL/SQLServer ODBC;Driver={Microsoft Visual FoxPro Driver};" + "SourceType=DBF;SourceDB=" + projPath + ";InternetTimeout=300000;Transact Updates=True";
ReadQs(Session["myQConn"].ToString());
}
public void ReadQs(string myConnString)
{
string mySelectQuery = "SELECT * FROM QUESTION";
OdbcConnection myConnection = new OdbcConnection(myConnString);
OdbcCommand myCommand = new OdbcCommand(mySelectQuery, myConnection);
myConnection.Open();
OdbcDataReader myReader;
myReader = myCommand.ExecuteReader();
plcQ.Controls.Add(new LiteralControl("<table>"));
decimal counter = 0;
string strMin = string.Empty;
string strMax = string.Empty;
string strConfirm = string.Empty;
while (myReader.Read())
{
counter = counter + 1;
strMin = myReader.GetString(2).Trim();
strMax = myReader.GetString(3).Trim();
strConfirm = myReader.GetString(6).Trim();
plcQ.Controls.Add(new LiteralControl("<tr>"));
// Create server-side ASP Update Button
Button btnUpdate = new Button();
btnUpdate.ID = "btnUpdate_" + counter;
btnUpdate.Text = "Update";
btnUpdate.Click += new System.EventHandler(this.btnUpdate_Click);
// Add button to placeholder
plcQ.Controls.Add(new LiteralControl("<td>"));
plcQ.Controls.Add(btnUpdate);
plcQ.Controls.Add(new LiteralControl("</td>"));
// Add HTML text input boxes to placeholder
plcQ.Controls.Add(new LiteralControl("<td><input type='text' name='minimum_" + counter + "' value='" + strMin + "'></td>"));
plcQ.Controls.Add(new LiteralControl("<td><input type='text' name='maximum_" + counter + "' value='" + strMax + "'></td>"));
// Add HTML drop down box to placeholder
plcQ.Controls.Add(new LiteralControl("<td><select name='confirm_" + counter + "'>"));
if(strConfirm == "T")
plcQ.Controls.Add(new LiteralControl("<option value='T' selected>T</option><option value='F'>F</option></select></td></tr>"));
else
plcQ.Controls.Add(new LiteralControl("<option value='T'>T</option><option value='F' selected>F</option></select></td></tr>"));
}
plcQ.Controls.Add(new LiteralControl("</table>"));
myReader.Close();
myConnection.Close();
}
So, the question is, when the user clicks btnUpdate_3, how do I get whatever they entered in minimum_3 (input text), maximum_3 (input text), and confirm_3 (select) so that I can do an update on my database??? (I have also tried using an html button control, but had the same issues) – HELP!
|
|
|
|
|
hi
I have a datagrid with a two colums. In the first column I have a checkbox in the header (headertemplate) and one for every row(ItemTemplate).
I find the checkbox in the itemtemplate easy with
<br />
cb = (CheckBox) dgi.Cells[0].Controls[1];<br />
but I cant seem to find the checkbox in the header. Ive also tried
<br />
cb = (CheckBox) this.dgOrganisation.FindControl("cbxAlla");<br />
with no results.
How do I find the checkbox?
|
|
|
|
|
Here is one solution:
foreach(DataGridItem dgi in dgOrganisation.Items)
{
if (dgi.ItemType == ListItemType.Header)
{
CheckBox cb = (CheckBox)dgi.Cells[0].Controls[1];
}
}
Haven't tried it out, but it'll do the trick
Hope it helps
Thomas
|
|
|
|
|
Hello, coders, I have a big question. I am gonna make a cd presentation with password protected sections but all my facilities will not have sence if the user browses the cd directory and opens the files there. So is there such a way to forbid browsing the directory in the cd?
|
|
|
|
|
No.
You might be able to mark the directory as hidden and system, then the users with default settings in the explorer won't see it.
You could encrypt the contents of the files. There is build in encryption in the framework.
---
b { font-weight: normal; }
|
|
|
|
|
Hi,
I want to call a webservice Asynchronously. I know using the Callback mechanism of .NET we can do it.For that we have to add web service in webreference.
But in my application i will not add any Webreference instead i will call webservices through my ForwardRequest method with parameters of webserviceURL,username,password.Here is my code.
public static XmlNode ForwardRequest(string webRequest, string userName, string password)
{
XmlNode resultNode = null;
try
{
WebResponse result = null;
XmlDocument webdoc = new XmlDocument();
string url = "";
string payload = "";
if (webRequest.IndexOf('?') != -1)
{
url = webRequest.Substring(0, webRequest.IndexOf('?'));
payload = webRequest.Substring(webRequest.IndexOf('?') + 1);
}
else
url = webRequest;
WebRequest req = WebRequest.Create(url);
req.Credentials = new NetworkCredential(userName, password);
req.Method = "POST";
req.ContentType = "application/x-www-form-urlencoded";
byte[] SomeBytes = null;
if (payload != null)
{
SomeBytes = Encoding.UTF8.GetBytes(payload);
req.ContentLength = SomeBytes.Length;
Stream newStream = req.GetRequestStream();
newStream.Write(SomeBytes, 0, SomeBytes.Length);
newStream.Close();
}
else
{
req.ContentLength = 0;
}
req.Timeout = Timeout.Infinite;
result = req.GetResponse();
Stream ReceiveStream = result.GetResponseStream();
webdoc.Load(ReceiveStream);
result.Close();
resultNode = webdoc.DocumentElement;
}
catch (Exception e)
{
}
return resultNode;
}
My question is how should i call webservice Asynchronously with my ForwardRequest(). Can anybody knows how to add callback mechanism of .NET to my ForwardRequest()
Thanks,
Vinoth
|
|
|
|
|
Here is a dotnet Project renamer for c# and VB.NET
http://www.soft4people.net/projectRenamer
and it is free;P...
|
|
|
|
|
Cheap-ass...
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
Hi to all,
i'm trying to execute a stored procedure via a web service.
i want to send a struct that contains the parameter of the stored procedure
public struct StoredProcParam
{
public string eParamName;
public SqlDbType eType;
public int eSize;
public ParameterDirection eDirection;
public object eValue;
}
when i create in my windows application an instance of the struct, i can't assign the element of the struct because the debugger consider the element as invalid
localhost.StoredProcParam[] oParam = new localhost.StoredProcParam[3];
oParam[0].eParamName = "@sNomChamp";
oParam[0].eType = localhost.SqlDbType.VarChar;
oParam[0].eSize = 50;
oParam[0].eDirection = localhost.ParameterDirection.Input;
oParam[0].eValue = e.FieldName;
moclsBdd.ExecuteStoredProcedure("sp_UpdatePays", oParam);
does any know how to put values in the elements of the struct and then pass it to the web method in the web service
thanks in advance
fady
|
|
|
|
|
You have to create the structures also:
localhost.StoredProcParam[] oParam = new localhost.StoredProcParam[3];<br />
oParam[0] = new StoredProcParam();<br />
oParam[1] = new StoredProcParam();<br />
oParam[2] = new StoredProcParam();
---
b { font-weight: normal; }
|
|
|
|
|
thanks a lot for your reply, it works very good.
i were badly stuck with this issue
thanks again,
fady
|
|
|
|
|
Hi and thanks to your reply, it works very good
i was badly stuck with this issue
thanks again
fady
|
|
|
|
|
Can i add a reference to them and include the Dll's with the app?
If so does anybody know exactly what dll's 'n' stuff that i will need?
Update: the message says "File or assembly name Microsoft.DirectX, or one of its dependencies, was not found."
|
|
|
|
|
That depends on which .DLL's your talking about. The DirectX .DLL's will have to be installed using the Redistributable installer. The Managed DirectX Interop .DLL's you can include with your app. These are the .DLL's you should be setting your reference to. You haven't done this judging by the error message you posted.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
|
|
Hello,
Is there a way to show an MDIChild form modally?
Thank you very much
|
|
|
|
|
No. MDI Child forms are not meant for this purpose.
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|