Showing posts with label build. Show all posts
Showing posts with label build. Show all posts

Saturday, March 24, 2012

Tagging in ASP.NET 2.0 - can anyone help, please?

Hello,

I have found lots of articles explaining how to build tag clouds in ASP.NET, they are very good. I have been looking for a very simple tutorial on how to allow users to tag a database entry like a photo or news article, or anything really, like on this forum - where you add tags for a new post. I can't find any. I'm quite new to this, and I would be really grateful if somone could explain how I can build a page where users can tag stuff, using a single textbox and commas as a separator for each word. Thats the bit which confuses me the most!

Thank you very much!

Jack.

Hi Jack,

There's a few steps involved, so I'll try to keep it short...

First, add a "Tags" table with the following fields to the database that will hold all of your tags:

Tags
- tagID (Integer)(Primary Key)(Identity)
- tagText (varchar(255))

Next, let's assume you already have a table that stores your Articles, and it has a primary key field named: "articleID". You would then create another table to tie multiple tags to an article:

ArticleTags
- articleID (Integer)(Not Null)
- tagID (Integer)(Not Null)

Now, without getting too far into a discussion about good architecture - let's keep things simple. Let's create classes that define our Article, Tag and ArticleTag tables:

public class Article
{
public int articleID;
public string name;
public string body;

public Article(string name, string body)
{
this.name = name;
this.body = body;
}

public void Insert()
{
//code to save an article goes here
//once article is saved, set the generated articleID into this object
this.articleID = ArticleManager.Insert(this);
}
}

public class Tag
{
public int tagID;
public string tagText;

public Tag(string tag)
{
this.tagText = tag;
}

public void Insert()
{
//first, see if tag already exists
Tag tag = TagManager.GetByTagText(this.tagText);
if (tag == null) //assumes that above method returns null if matching tag not found
{
//once tag is saved, set the generated tagID into this object
this.tagID = TagManager.Insert(this);
}
else
{
//tag exists, grab the tagID
this.tagID = tag.tagID;
}
}
}

public class ArticleTag
{
public int articleID;
public int tagID;

public ArticleTag(int articleID, int tagID)
{
this.articleID = articleID;
this.tagID = tagID;
}

public void Insert()
{
ArticleTagManager.Insert(this);
}
}

Let's also create a helper class that holds multiple "Tag" objects:

public class TagList : List<Tag>
{
public TagList() { }
}

OK, that's the backend stuff done. Now all we need to do is get the tags from the user, parse them out and use these classes to save them to the database. Let's assume that we're on a page where we are creating a new Article and Tags for that article at the same time:

After the "Save" button is clicked, so the code goes here:

protected void btnSave_Click(object sender, EventArgs e)
{
//build up the new Article object
Article art = new Article(txtName.Text, txtBody.Text);

//now, let's grab the tags which are seperated by commas
TagList tList = new TagList();
string[] tags = txtTags.Text.Split(',');
//loop through the resulting array
foreach (string t in tags)
{
//first, make sure there's more than just a space
if (t.Trim().Length > 0)
{
Tag tag = new Tag(t.Trim());
//add tag to the list
tList.Add(tag);
}
}
this.mNewTagList = tList;

//now, save article and tags
art.Insert();

//make sure it saved and we have an articleID to use
if (art.articleID > 0)
{
//now save each tag, and create association between the tag and the article
foreach(Tag t in tList)
{
t.Insert();

//make sure we have a tagID to work with
if (t.tagID > 0)
{
//create a new association
ArticleTag at = new ArticleTag(art.articleID, t.tagID);
at.Insert();
}
}
}
}

That's it! Hope that helps!

Chad

Thursday, March 22, 2012

taking a build of asp.net 2005 application.

hai

please help me. when i am trying to get a build i got this problem. here i am giving that error. please if any one can resolve it respond to this.

Compilation Error

Description:An error occurred during the compilation of a resource required to service this request. Please review the following specific error details and modify your source code appropriately.

Compiler Error Message:CS0030: Cannot convert type 'ASP.login_aspx' to 'System.Web.UI.WebControls.Login'

Source Error:

Line 120: public login_aspx() {Line 121: string[] dependencies;Line 122: ((Login)(this)).AppRelativeVirtualPath = "~/Login.aspx";Line 123: if ((global::ASP.login_aspx.@dotnet.itags.org.__initialized == false)) {Line 124: global::ASP.login_aspx.@dotnet.itags.org.__stringResource = this.ReadStringResource();


Source File: c:\WINNT\Microsoft.NET\Framework\v2.0.50727\Temporary ASP.NET Files\its\6b99b5ef\95ca6e32\App_Web_login.aspx.cdcab7d2.b6tyqpzy.0.cs Line: 122

Hi and Welcome to ASP.NET Forum!

this in your context refers to System.Web.UI.Page and you are trying to cast it to Login (which of type System.Web.UI.WebControls.Login) which cannot be done. What you are trying to do? Are you trying to get a reference to the page?

Thanks

Taking over project

Anyone got any pointers on taking over code from another consultant? I have
some ASP.NET code, some assemblies with the projects to build the dlls in
the bin folder, and all the code and pages that are on the production
server. Now I am going to have to set up the development environment. This
does not look as simple as opening the project in VS.NET or is it?Hi Ron,

You might find it faster to create your own project in VS.NET and start
dropping the other person's .aspx and .vb files in it. See if you can get it
to build before you make any changes.

Although you can sometimes open someone else's solution or project, there
are usually path changes and Web site configuration setting that don't match
up. You spend more time trying to make it work than you would creating your
own project and copying the files.

Ken

"Ron Weldy" <ronweldy@.msn.com> wrote in message
news:%23xM8XvKAFHA.2552@.TK2MSFTNGP09.phx.gbl...
> Anyone got any pointers on taking over code from another consultant? I
> have some ASP.NET code, some assemblies with the projects to build the
> dlls in the bin folder, and all the code and pages that are on the
> production server. Now I am going to have to set up the development
> environment. This does not look as simple as opening the project in VS.NET
> or is it?
Good point. Thanks!

"Ken Cox [Microsoft MVP]" <BANSPAMken_cox@.sympatico.ca> wrote in message
news:u1skl0KAFHA.1400@.TK2MSFTNGP11.phx.gbl...
> Hi Ron,
> You might find it faster to create your own project in VS.NET and start
> dropping the other person's .aspx and .vb files in it. See if you can get
> it to build before you make any changes.
> Although you can sometimes open someone else's solution or project, there
> are usually path changes and Web site configuration setting that don't
> match up. You spend more time trying to make it work than you would
> creating your own project and copying the files.
> Ken
> "Ron Weldy" <ronweldy@.msn.com> wrote in message
> news:%23xM8XvKAFHA.2552@.TK2MSFTNGP09.phx.gbl...
>> Anyone got any pointers on taking over code from another consultant? I
>> have some ASP.NET code, some assemblies with the projects to build the
>> dlls in the bin folder, and all the code and pages that are on the
>> production server. Now I am going to have to set up the development
>> environment. This does not look as simple as opening the project in
>> VS.NET or is it?
>

Taking over project

Anyone got any pointers on taking over code from another consultant? I have
some ASP.NET code, some assemblies with the projects to build the dlls in
the bin folder, and all the code and pages that are on the production
server. Now I am going to have to set up the development environment. This
does not look as simple as opening the project in VS.NET or is it?Hi Ron,
You might find it faster to create your own project in VS.NET and start
dropping the other person's .aspx and .vb files in it. See if you can get it
to build before you make any changes.
Although you can sometimes open someone else's solution or project, there
are usually path changes and Web site configuration setting that don't match
up. You spend more time trying to make it work than you would creating your
own project and copying the files.
Ken
"Ron Weldy" <ronweldy@.msn.com> wrote in message
news:%23xM8XvKAFHA.2552@.TK2MSFTNGP09.phx.gbl...
> Anyone got any pointers on taking over code from another consultant? I
> have some ASP.NET code, some assemblies with the projects to build the
> dlls in the bin folder, and all the code and pages that are on the
> production server. Now I am going to have to set up the development
> environment. This does not look as simple as opening the project in VS.NET
> or is it?
>
Good point. Thanks!
"Ken Cox [Microsoft MVP]" <BANSPAMken_cox@.sympatico.ca> wrote in message
news:u1skl0KAFHA.1400@.TK2MSFTNGP11.phx.gbl...
> Hi Ron,
> You might find it faster to create your own project in VS.NET and start
> dropping the other person's .aspx and .vb files in it. See if you can get
> it to build before you make any changes.
> Although you can sometimes open someone else's solution or project, there
> are usually path changes and Web site configuration setting that don't
> match up. You spend more time trying to make it work than you would
> creating your own project and copying the files.
> Ken
> "Ron Weldy" <ronweldy@.msn.com> wrote in message
> news:%23xM8XvKAFHA.2552@.TK2MSFTNGP09.phx.gbl...
>