|
Then make it public or internal and don't decorate it with the WebMethod attribute.
Realistically all web method calls should be immediate proxy calls to another class anyway.
Need a C# Consultant? I'm available.
Happiness in intelligent people is the rarest thing I know. -- Ernest Hemingway
|
|
|
|
|
Greetings,
I will try to describe this problem in as much details as I can.
Task: Create N HTML page withing a folder-structure based on N grandparent-parent-child relationships.
Data structure:
TopicID - int
ParentTopicID int
TopicName - nvarchar(4000)
Sample data
TopicID ParentTopicID TopicName
0 0 Computers
1 1 Programming
2 1 C#
3 1 C++
4 1 Java
5 1 Perl
6 0 Operating systems
7 6 Windows 2000
8 6 Windows XP
9 6 Unix
Output which to achieve:
Folder: Computer
File: Computers.html
Contents:
Programming
Operating Systems
Folder: Computer/Programming
File: Programming.html
Contents:
C#
C++
Java
Perl
and so forth....
The question is, what is the best algorithm to use to achive the above results?
Thank you very much in advanced!
Arsen
|
|
|
|
|
Smells a bit like homework...
|
|
|
|
|
VarChar255 wrote: The question is, what is the best algorithm to use to achive the above results?
I suggest the critical thinking algorithm. Good luck on your assignment, it's an interesting one.
|
|
|
|
|
If the datasource for this is SQL Server 2005, then take a look at using Common Table Expressions (CTE). They will sort this out for you no problem.
Deja View - the feeling that you've seen this post before.
|
|
|
|
|
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.
Arsen
|
|
|
|
|
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
|
|
|
|