Advertise with us
Control Panel
Forum
Hosting Help
ASP.NET 4.5 & SQL 2012 Hosting
Resources
Notice
Login
Members
Shared Hosting
|
Upgrade
|
Advertise
|
Tutorials
|
Home
»
Questions & Answers
»
tuitterMain.aspx (blog website with different futures)
tuitterMain.aspx (blog website with different futures)
02 Jun, 12
Author:
Sylvie Eymin
I have a very basic understanding of C# but i want to do a small blog for my website as following:
- displaying the tuits contained in tuitterMessages.txt within
TuitterMain.aspx. For now, display all tuits without considering the follow/unfollow features.
This is the code that i have but don't work...The tuitterMessages.text does not appear in my tuitListBox....What is wrong?
}
protected void Page_Load(object sender, EventArgs e)
{
//Call text message in the Text Box
string[] tuitMessagesArray = File.ReadAllLines(Server.MapPath( ) + /App_Data/tuitterMessages.txt);
for (int n = 0; n < tuitMessagesArray.Length; n++)
{
tuitListBox.Text = tuitListBox.Text + \n + tuitMessagesArray[i];
}
- Then, continue with the ‘Add Tuit’ functionality.
i should be able to add tuit from my tuitMessagesTextBox, here is also my code but does not work either...what is wrong....?
}
protected void tuitMessagesTextBox_TextChanged(object sender, EventArgs e)
{
// drag text from tuitMessagesTextBox to tuitListBox
// Use AppendAllText to write in the box for the first line/box
File.AppendAllText(Server.MapPath( ) + /App_Data/tuitterMessages.txt, System.Environment.NewLine + tuitMessagesTextBox.Text);
tuitListBox.Text = ;
string[] tuitMessagesArray = File.ReadAllLines(Server.MapPath( ) + /App_Data/tuitterMessages.txt);
for (int i = 0; i < tuitMessagesArray.Length; i++)
{
tuitListBox.Text = tuitListBox.Text + \n + tuitMessagesArray[i];
}
}
If i want to reverse this tuit, i did following code but it is lot of Mistakes in it:
string[] tuitsList = new List<string>();
int g = 0;
tuitsList.Add(g++);
Console.WriteLine();
foreach(string tuit in tuitsList)
{
Console.WriteLine(tuit);
}
tuitsList.Reverse();
Console.WriteLine();
foreach(string tuit in tuitsList)
{
Console.WriteLine(tuit);
}
-I must write the C# code that takes care of displaying the number of tuits of the current user as well as the total number of tuits. Make sure both numbers are updated when adding new tuits.
i have one nbTuitLabel and one nbFollowingLabel,and a nbTotalTuitsLabel but i do not know how to declare those codes has someone an Idea, please?
- I must continue with the C# code that handled the ‘Follow’ functionality (without considering the Unfollow feature).
i have a whoToFollowDropDownList and a whoToFollowButton, i must write some code in a prerender page method as follow and some int the whoToFollowButton, this is what i have, but i do not know how i ahve to do it that it works...:
protected void Page_Prerender(object sender, ImageClickEventArgs e)
{
what is to write in here????
}
protected void whoToFollowImageButton_Click(object sender, ImageClickEventArgs e)
{
string[] tuitterNameArray = File.ReadAllLines(Server.MapPath(~ + /App_Data/tuitterUsers.txt));
string[] fileNameArray;
for (int i = 0; i < tuitterNameArray.Length; i++)
{
fileNameArray = tuitterNameArray[i].Split(' ');
whoToFollowDropDownList.Items.Add(fileNameArray[0]);
How it is if i want to remove from that textBox the whoToFollow by clicking on the button:
is this work?
whoToFollowDropDownList.Items.Remove(whoToFollowDropDownList.SelectedValue);
- i must update the C# code in charge of displaying tuits based on the changes implemented in the below step . Only the tuits of the current user and the ‘followed’ users shall be displayed.
But how to do that???
I should write the C# code handling the Unfollow feature.
here i am lost. how to do that? can someone help please? This will be really appreciated. Thanks.
Answers .............
Author:
Nishanth Mohan
Posted Date: 04 Jun, 12
Use like this:
tuitListBox.Items.Add(new ListItem(tuitMessagesArray[i], tuitMessagesArray[i]));
Please give feedback on my new website:
http://aspspider.info/donatecarcalifornia
Author:
Sylvie Eymin
Posted Date: 05 Jun, 12
Thanks Nisanth, but where shall i put this please?
tuitTextBox.Items.Add(new ListItem(tuitterMessagesArray[i], tuitterMessagesArray[i]));
It is not better there to put this in a nested loop?
Author:
Sylvie Eymin
Posted Date: 05 Jun, 12
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.IO;
using System.Web.UI;
using System.Web.UI.WebControls;
public partial class TuitterWebste_TuitterLogin : System.Web.UI.Page
{
protected void Page_PreRender(object sender, EventArgs e)
{
//Populate unfollowDropDownList with users that want to follow.
string[] tuitterFollowerArray = File.ReadAllLines(Server.MapPath( ) + /App_Data/tuitterUsers.txt);
string[] userFollowerPair;
for (int h = 1; h < tuitterFollowerArray.Length; h++)
{
userFollowerPair = tuitterFollowerArray[h].Split(' ');
}
for (int v = 0; v <= unfollowDropDownList.Items.Count; v++)
{
}
//creating array for Tuit messages
string[] tuitterArray = File.ReadAllLines(Server.MapPath() + /App_Data/tuitterMessages.txt);
string[] tuitterMessageArray = File.ReadAllLines(Server.MapPath( ) + /App_Data/tuitterMessages.txt);
//reverse tuitMessages in Array
Array.Reverse(tuitterMessageArray);
//Empty the tuitTextBox
tuitTextBox.Text = ;
//displaying the tuit messages
for (int i = 0; i < tuitterMessageArray.Length; i++)
{
tuitTextBox.Text += tuitterMessageArray[i] + System.Environment.NewLine;
}
//displaying the tuit messages
for (int i = 0; i < tuitterMessageArray.Length; i += 3)
{
}
}
protected void Page_Load(object sender, EventArgs e)
{
string[] tuitterNameArray = File.ReadAllLines(Server.MapPath( ) + /App_Data/tuitterUsers.txt);
//Populate followDropDownList with users that you can follow.
if (!IsPostBack)
{
}
for (int i = 1; i < tuitterNameArray.Length; i++)
{
string[] userNamePair = tuitterNameArray[i].Split(' ');
followDropDownList.Items.Add(userNamePair[0]);
// use a session to greet User per his name.
try
{
string usernameString = Session[User].ToString();
welcomeLabel.Text = Welcome + usernameString + !;
welcomeLabel.Text = Convert.ToString(Welcome + Session[User]);
}
catch
{
Response.Redirect(TuitterLogIn.aspx);
}
//creating array for Tuit messages
string[] tuitterArray = File.ReadAllLines(Server.MapPath() + /App_Data/tuitterMessages.txt);
string[] tuitterMessageArray = File.ReadAllLines(Server.MapPath( ) + /App_Data/tuitterMessages.txt);
//reverse tuitMessages in Array
Array.Reverse(tuitterMessageArray);
//displaying total tuits
for (int j = 0; j < tuitterMessageArray.Length; j++)
{
string[] splitName = tuitterMessageArray[j].Split(' ');
totalNbLabel.Text = Convert.ToString(tuitterMessageArray.Length / 3);
}
//displaying tuits by current user
int counter = 0;
for (int g = 0; g < tuitterMessageArray.Length; g++)
{
if (tuitTextBox.Text == tuitterMessageArray[g].ToString())
{
tuitTextBox.Text += tuitterMessageArray[g].ToString();
counter++;
tuitNbLabel.Text = counter.ToString();
}
}
//displaying follower by current user
for (int k = 0; k < tuitterMessageArray.Length / 3; k++)
{
if (unfollowDropDownList.Text == tuitterMessageArray[k].ToString())
{
unfollowDropDownList.Text += tuitterMessageArray[k].ToString();
counter++;
followingNbLabel.Text = counter.ToString();
}
}
}
}
protected void tuitterImageButton_Click(object sender, ImageClickEventArgs e)
{
// drag blog from tuitMessagesTextBox to tuitTextBox
// Use AppendAllText to write in the box for the first line/box
File.AppendAllText(Server.MapPath( ) + /App_Data/tuitterMessages.txt, System.Environment.NewLine + (\n) + DateTime.Now.ToString() +(\n) + tuitMessagesTextBox.Text + (\n) + welcomeLabel.Text);
string[] tuitterMessageArray = File.ReadAllLines(Server.MapPath( ) + /App_Data/tuitterMessages.txt);
//reverse tuitMessages in Array
Array.Reverse(tuitterMessageArray);
for (int i = 0; i < tuitterMessageArray.Length; i++)
{
tuitTextBox.Text = tuitTextBox.Text + \n + tuitterMessageArray[i];
}
}
protected void followImageButton_Click(object sender, ImageClickEventArgs e)
{
// drag can follow tuitter in the unfollow box
unfollowDropDownList.Items.Add(followDropDownList.SelectedValue);
//selected user is going to the i follow box when the follow button is clicked
followDropDownList.Items.Remove(followDropDownList.SelectedValue);
}
protected void unfollowImageButton_Click(object sender, ImageClickEventArgs e)
{
//Populate unfollowDropDownList with users that i want to follow.
followDropDownList.Items.Add(unfollowDropDownList.SelectedValue);
//selected user is going back to the i can follow box when the follow button is clicked
unfollowDropDownList.Items.Remove(unfollowDropDownList.SelectedValue);
}
protected void tuitTextBox_SelectedIndexChanged(object sender, EventArgs e)
{
}
}
this is the blog but the labels calculation does not work as i expected, and i should be able to show in my tuittermessage.text by login with tom for example just his tuit(s) then the tuits from the people he follow but not all tuit in blog? who can help please? Thanks.
You must
login
to post answer for this question.
Total
members
:
250994
Average new registrations per day (in last 7 days):
8
New Registration:
Open
Register Now
Talk to Webmaster
Tony John
Facebook
Google+
Twitter
Advertise
Privacy Policy
Terms of use
Contact Us
SpiderWorks Technologies Pvt Ltd.
All Rights Reserved.