|
VarChar255 wrote: No not homework at all... actually one of my developers is having trouble with this, he wrote the code but i'd like to get some opinions from others on what patterns they use.
OK, lets flip this around then. What patterns would you use and we'll tell you whether we agree and which of your options sounds like the best way to us!
If you're telling the truth, and this really isn't homework, then you'll be willing and able to provide some responses. More likely we will see no response from you whatsoever.
|
|
|
|
|
Here is what my developer has implemented (excerpts)
void ProcesstopicChildren(DataTable dttopic)
{
similar while loop, but calling processtopic within whileloop.
}
main()
{
DataTable dtChildtopic;
DataTable dtParenttopic;
ItopicManager topicManager; // this is the SQL connector to call the SQL.
int ParenttopicID;
ParenttopicID = 8; // Just as a test
dtParenttopic = topicManager.GettopicView(ParenttopicID);
while(dttopic.Rows.Count > 0)
{
ParenttopicID = int.Parse(dtParenttopic.Rows[ParenttopicCount]["ParenttopicID"].ToString());
dttopic = topicManager.GettopicView(ParenttopicID);
ParenttopicCount++;
}
}
|
|
|
|
|
Jus want to know which one wil be performance wise better either static or session variable?
If suppose i want to maintain one instance specific data(E.g: username) which one i should prefer to go for?
How does the static variable stored in Memory?
I believe static variable will be maintained as a single copy in Application domain.if it true then how does it allows to store instance specific data.
Please clarify me..
Regards,
Murugs.
|
|
|
|
|
P.Murugs wrote: Please clarify me..
There are actually very fine articles beyond the documentation for ASP.NET Application and Session objects on MSDN. Have you read the documentation and articles? If you find them confusing please explain which specific part is not clear?
|
|
|
|
|
Yes..i have read some articles.
My query is if both the session and static variable allows us to store instance specific data's which one we opt to go for?
Tell me in terms of performance..
Thanks..
|
|
|
|
|
I can't open any page in my website because they also auto switch to login.aspx page ? Why? Here is my code in file login.aspx :
private bool ValidateUser( string userName, string passWord )
{
SqlConnection conn;
SqlCommand cmd;
string lookupPassword = null;
// Check for invalid userName.
// userName must not be null and must be between 1 and 15 characters.
if ( ( null == userName ) || ( 0 == userName.Length ) || ( userName.Length > 15 ) )
{
System.Diagnostics.Trace.WriteLine( "[ValidateUser] Input validation of userName failed." );
return false;
}
// Check for invalid passWord.
// passWord must not be null and must be between 1 and 25 characters.
if ( ( null == passWord ) || ( 0 == passWord.Length ) || ( passWord.Length > 25 ) )
{
System.Diagnostics.Trace.WriteLine( "[ValidateUser] Input validation of passWord failed." );
return false;
}
try
{
// Consult with your SQL Server administrator for an appropriate connection
// string to use to connect to your local SQL Server.
conn = new SqlConnection( "server=localhost;Integrated Security=SSPI;database=HopNhacProj" );
conn.Open();
// Create SqlCommand to select pwd field from users table given supplied userName.
cmd = new SqlCommand( "Select Matkhau from tblThanhVien where TenDn=@userName", conn );
cmd.Parameters.Add( "@userName", SqlDbType.VarChar, 25 );
cmd.Parameters["@userName"].Value = userName;
// Execute command and fetch pwd field into lookupPassword string.
lookupPassword = (string) cmd.ExecuteScalar();
// Cleanup command and connection objects.
cmd.Dispose();
conn.Dispose();
}
catch ( Exception ex )
{
// Add error handling here for debugging.
// This error message should not be sent back to the caller.
System.Diagnostics.Trace.WriteLine( "[ValidateUser] Exception " + ex.Message );
}
// If no password found, return false.
if ( null == lookupPassword )
{
// You could write failed login attempts here to event log for additional security.
//lblMsg.Visible=false;
return false;
}
// Compare lookupPassword and input passWord, using a case-sensitive comparison.
return ( 0 == string.Compare( lookupPassword, passWord, false ) );
}
private void btnDangNhap_Click(object sender, System.Web.UI.ImageClickEventArgs e) //button login
{
if (ValidateUser(txtUserName.Text,txtUserPass.Text) )
{
FormsAuthenticationTicket tkt;
string cookiestr;
HttpCookie ck;
tkt = new FormsAuthenticationTicket(1, txtUserName.Text, DateTime.Now,
DateTime.Now.AddMinutes(30), chkPersistCookie.Checked, "your custom data");
cookiestr = FormsAuthentication.Encrypt(tkt);
ck = new HttpCookie(FormsAuthentication.FormsCookieName, cookiestr);
if (chkPersistCookie.Checked)
ck.Expires=tkt.Expiration;
ck.Path = FormsAuthentication.FormsCookiePath;
Response.Cookies.Add(ck);
string strRedirect;
strRedirect = Request["ReturnUrl"];
if (strRedirect==null)
strRedirect = "~/default.aspx";
Session["userName"] = txtUserName.Text;
Response.Redirect(strRedirect, true);
}
else
{
//Response.Redirect("../SubPages/Login.aspx", true);
lblMsg.Visible = true;
lblMsg.Text = "Tên đăng nhập hoặc mật khẩu không hợp lệ !";
txtUserName.Text = "";
txtUserPass.Text = "";
}
}
nothing
|
|
|
|
|
whale84 wrote: Why?
Indeed. What actually happens when the code executes? That might explain the "why", don't you think?
|
|
|
|
|
I mean I set as start page for default.aspx at the root of my solution.But when I compile ,I saw in Address bar of browser show the link of default.aspx but it switch to show the login.aspx page immediately.I try to set as start page for another page in my solution and the browser also show the login.aspx page like that.
In file web.config, i set :
<authentication mode="Forms">
<forms name=".ASPXFORMS" loginUrl="./SubPages/Login.aspx"
protection="All" path="/" timeout="60" />
</authentication>
nothing
|
|
|
|
|
Hi,
I like to know if there is a way to have multi color Text
like some text in red color The other Green and so on...
i tried this :
RichTextBox1.ForeColor = Color.Red;<br />
RichTextBox1.Text +="try Red";<br />
RichTextBox1.ForeColor = Color.Green<br />
RichTextBox1.Text +="try Green";
But of course it remember the last ForeColor;
maybe a nother Control to use will help???
THANKS
Have Fun
Never forget it
|
|
|
|
|
IIRC you have to use the SelectionColor to do this. For instance:
int pos = RichTextBox1.Text.Length;
RichTextBox1.SelectionStart = pos;
RichTextBox1.SelectionColor = Color.Red;
RichTextBox1.Text += "try red";
pos = RichTextBox1.Text.Length;
RichTextBox1.SelectionStart = pos;
RichTextBox1.SelectionColor = Color.Green;
RichTextBox1.Text += " try green";
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Sorry
Not working,
THNKS,
Have Fun
Never forget it
|
|
|
|
|
Try this:
int pos = rtb.Text.Length;
rtb.Font = new Font(rtb.Font.FontFamily, rtb.Font.Size);
rtb.Text += "Hello";
rtb.SelectionStart = pos;
rtb.SelectionLength = 5;
rtb.SelectionColor = Color.Red;
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
Wow, It Works
THNKS A million
Have Fun
Never forget it
|
|
|
|
|
Hi,
I am beginner in C#. I have a problem while coding in C#. The problem is somewhere in the application, i need to change the color of a Title bar of a window. Yes, title bar is where system menu, minimize,maximize buttons are located. Can anybody help me in doing this in C#? Pls help me ASAP... Thanks in advance
Regards,
Jitin
|
|
|
|
|
coder_help wrote: title bar is where system
Jus tas u said, i'ts System based
Change Yuor Compuetr Theme and u'll see That i'ts Changes also
I never Heard That U can Do This
Have Fun
Never forget it
|
|
|
|
|
if this is really a critical requirement , you can make the form
borderless and create your own title bar
(3 buttons a label and change the color of the label)
When you get mad...THINK twice that the only advice
Tamimi - Code
|
|
|
|
|
I want to this in C#. as per your suggestion, if i carry on then i need to handle lot of functionality for the title bar... what do u think for alternative functionality? pls reply me..
|
|
|
|
|
Is there any simple alternative ?
|
|
|
|
|
no. you have to do it all yourself. a lot of effort for a small result.
Luc Pattyn [Forum Guidelines] [My Articles]
this months tips:
- use PRE tags to preserve formatting when showing multi-line code snippets
- before you ask a question here, search CodeProject, then Google
|
|
|
|
|
I just did this and wondered the same thing. For the Title Bar, you have to create a bool (for example, mouseIsDown to false), picturebox, and three buttons. Then, for that picturebox, look for the MouseDown, MouseMove, and MouseUp events. THen, in MouseDown, have the bool set true. In mouseMove:
blah blah event<br />
{<br />
if (mouseIsDown == true)<br />
(change the form location to reach the mouses)<br />
}
Then, in MouseUp, set mouseIsDown to false.
There's more to it, but I hope it gives you the idea.
Good luck
- "Achieving all knowledge does not mean achieving all wisdom."
- "What's THIS button do... ... ... ?"
|
|
|
|
|
some skins may do that,but i forgot its' name
CSharper
|
|
|
|
|
Dear all,
I have this scenario:
I want to have a chart on which i plot 4 lines .. i.e. 4 line graphs. This means that somehow I have to use more than I series.
Any idea on how to create an appropriate data source for this. I already have a class named coordinate which has an x value and a y value. The thing i am missing is how to put multiples of these in order to have 4 serieses.
Thanks a lot,
Chris
|
|
|
|
|
ChrisFarrugia wrote: I already have a class named coordinate
ChrisFarrugia wrote: how to put multiples of these in order
Maybe a collection?
|
|
|
|
|
Thanks a lot for your reply but I think I did not manage to explain well what i meant.
What I want is a way to have 4 coordinates collections each of which representing a line graph on the same axis.
I hope I made myself clearer.
Thanks Chris
|
|
|
|
|
ChrisFarrugia wrote: I want is a way to have 4 coordinates collections
So if you can have a collection of coordinates can't you have a collection of coordinate collections? You have not provided any specific problem definition. It seems you just don't know how to use collections.
|
|
|
|