I'm using asp.net/C# and I'm looking to create unique(?) uris for a small CMS system I am creating.
I am generating the uri segment from my articles title, so for example if the title is "My amazing article" the uri would be www.website.com/news/my-amazing-article
There are two parts to this. Firstly, which characters do you think I need to strip out? I am replacing spaces with "-" and I think I should strip out the "/" character too. Can you think of any more that might cause problems? "?" perhaps? Should I remove all non-alpha characters?
Second question, above I mentioned the uris MAY need to be unique. I was going to check the uri list before adding to ensure uniqueness, however I see stack overflow uses a number plus a uri. This I assume allows titles to be duplicated?
I want to redirect to "~/City/Göteborg", but if I just write Response.Redirect("~/City/Göteborg"); I will end up with an ugly URL in the address-bar like this: http://www.mysite.com/City/G%c3%b6teborg..
So my question is how to redirect to obtain a clean url like http://www.mysite.com/City/Göteborg?
I need to be able to remove non-XHTML tags from a string containing XHTML that has been stored in a database. The string also contains references for controls (e.g. ) inside the XHTML, but I need clean XHTML with all standard tag contents unchanged.
These control tags are varied (they could be any ASP.NET control), so there are too many to go looking for each one and remove them. The way they are closed is also varied, so not all of them have closing tags, some are self closing.
How can I go about doing this? I've found some HTML cleaners on-line for including in my project, but they either remove everything or just HTML encode the entire string.
Also, I'm dealing with parts of XHTML documents, not entire documents - don't know if that makes a difference.
An example (not fantastic, but gives you the idea of what I'm working with):
<p><mycontrols:mycontrol myproperty="hello world" myproperty2="7"><SPAN><a href="#"><img title="an example image" height="68" width="180" alt="an example image" src="images/example1.gif"></a></span></mycontrols:mycontrol><a href="#"></a></p>
How to Split and strip X string values into separate variables? X has string value of
itemA=myvalue&itemB=anothervalue&itemC=andanother
I have 3 strings (var1,var2,var3) to hold the values of the stripped values. Find in string X "itemA=" copy everything after "=" character until "&" character OR if no "&" character is found copy until end of string (store this value into var1) Find in string X "itemB=" copy everything after "=" character until "&" character OR if no "&" character is found copy until end of string (store this value into var2)
Find in string X "itemB=" copy everything after "=" character until "&" character OR if no "&" character is found copy until end of string (store this value into var3)
Is it at all possible to use IIS7's rewrite capability in web.config to strip a particular HTTP header from a client request?We have an application that makes an HTTP POST to our website, and apparently the request contains the HTTP Expect header. Previously this was not a problem, but we've switched hosts and now the site is returning HTTP error 417 Expectation failed. So the real solution is to fix the software so it doesn't send the Expect header, but that can't happen soon enough for the folks in charge, who'd like to come up with an immediate web-based fix.I've used ISAPI_Rewrite before and I've read that it can strip a header, and the new host claimed they had ISAPI installed... but that seems to have been a lie, as I cannot get it to work, and support's only response on the subject is "use IIS7 Rewrite instead."
I'm about to start an application that will allow users to upload an amount of text to a SQL database via an ASP.NET webform. I am certain that many users will cut and paste the text from Word, together with all the formatting and other baggage that Word creates. I'm looking for a way of programatically stripping out all of this stuff and leave just plain text.
I've got a literal control to display the username of the user logged into our companies intranet system, originally I had a LoginName control but couldn't get strip to remove the domain from the username (as the format is domainnameusername) so I'm trying it this way.
I have used datagridview to display certain data to users...
It works f9 but what I am concerned with is that there are a few columns having large text...n the text moves to the next line...i want that after a fixed length of letters it should display "......"
I have a string with 100 characters and it is for me too long in one line. I want to make NewLine after each 25 characters. For example:
Instead: "Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua."
I have a application that takes a tab delimited text file parses and the inserts the data. Some of the data has international characters. My problem is it appears that my application is changing the characters. For Example the file might contain something lke this Andrlová and is converting it to this Andrlov�
I am passing this into a sproc. The datatypes for my paramater & DB Field is nVarChar(50). If I insert the data directly into my table or if I call my sproc from a query window and pass in some data it works fine, but when my app touches the data it appears to get messed with.
I'm considering to host WCF Rest Service that i've built on IIS 7. The URL to access my service will be something like
[URL]
Recently, i've been looking to some REST API implementation with a clean URL like Yahoo API
[URL]
I'm wondering what will be the best WCF host environment (e.g. Windows Service) or any solution (e.g. URL rewrite module) considering that I dont want to have application name and .svc in my URL so that I can have a completely clean URL for my REST API
My C# site allows users to submit HTML to be displayed on the site. I would like to limit the tags and attributes allowed for the HTML, but am unable to figure out how to do this in .net.
I've tried using Html Agility Pack, but I don't see how to modify the HTML, I can see how to go through the HTML and find certain data, but actually generating an output file is baffling me.
Does anyone have a good example for cleaning up HTML in .net? The agility pack might be the answer, but the documentation is lacking.
I am wondering having clear web.config file could be good but you know some shared web hosting companies don't allow us to touch things like machine.config and etc.
So If a lot of things have been moved onto machine.config, then will we be allowed to change things like we used to through web.config file.
There is an image for the surface, and a text is written on the image for 184 rows of date.. Thus, it is expected to see 184 different text written image files are generated with all the same background images. (The code is declared below...)
The problem is that the first text is written for all 184 different data.. I think I have to remove something in the loop. But what is that ??
Is there a better way to write the code below? I have quite a few blocks that are similar, and this is making the code in the Viewpage very messy to work with. The data value with the associated label only needs to be output when certain conditions are met, which is almost always if the value is not null. The options I can think is to use a response.write to atleast minimize the usage of the ASP script tags, or to format the webpage is such a way that the label displays with an appropriate n/a type value.
I once asked for a way to let a linkbutton pass more than one value in the commandArgument and then I reached the approach where I pass a string of multiple values separated by any character and split it into it's original parts...that didn't work out I don't know what was wrong with the splitting!
Now I tried the only solution I got, which is created a user control of the LinkButton and add properties to accept any values nedeed!...could you please tell me what's wrong with my 2 approaches and which is better ?
The first question can be found here : link text
and this is the code for the user control approach >>
MultivaluedLinkButton.ascx : <asp:LinkButton ID="LnkBtnSort" runat="server" Text="Sort" OnClick="LnkBtnSort_Clicked"/> MultivaluedLinkButton.ascx.cs : public partial class MultivaluedLinkButton : System.Web.UI.UserControl { public event EventHandler Click; private int _sortingType; private string _sortingFactor; private string _text; public int SortingType { set { _sortingType = value; } get { return _sortingType; } } public string SortingFactor { set { _sortingFactor = value; } get { return _sortingFactor.ToString(); } } //public string Text //{ // set { _text = value; } // get { return _text.ToString(); } //} protected void LnkBtnSort_Clicked(object sender, EventArgs e) { if( Click != null ) { this.Click(this, EventArgs.Empty); } } } Finally, Here's the implementation of my control inside an aspx page: protected void MultivaluedLinkButton1_Clicked(object sender, EventArgs e) { MultivaluedLinkButton ctrl = (MultivaluedLinkButton)sender; using (SqlConnection cn1 = new SqlConnection(ConfigurationManager.ConnectionStrings["testConnectionString"].ConnectionString)) { using (SqlCommand cm1 = new SqlCommand(commandString2, cn1)) { cm1.Parameters.Add("@arrange_by_id", System.Data.SqlDbType.Int); cm1.Parameters["@arrange_by_id"].Value = ctrl.SortingType; cn1.Open(); using (SqlDataReader dr1 = cm1.ExecuteReader()) { SortBy_rpt.DataSource = dr1; SortBy_rpt.DataBind(); } } } }
The item template of the repeater in the implementation page :
I would like to add html attributes to form inputs, specifically disabled="disabled" in addition to others. I have conditional logic in the Controller that determines whether to add this html attribute or not that sets a bool IsDisabled flag in my ViewModel e.g.
Except that Add returns void, and there is no such thing as AddConditional. Is there something like an MVC HtmlAttributeBuilder class, or should I just extend Dictionary with these two extension methods?
I haven't been able to find a post about this, but the HTMLEditor is finally a rich text editor that properly removes word formatting without messaging up other stuff (thank god!). However, because I know my users, I would like for this 'paste as word' mode to be always on whenever they paste, how can I accomplish this?
I am completely new to ASP.NET programming, and was asked to work on a small project involving ASP.NET, VB (which I am new to as well) and Microsoft SQL Server 2005.
Being used to php/java I was hoping to find some kind of similar API to php.net and the javadoc. It would be very useful to have as I would prefer to work with a text editor, instead of using DreamWeaver or Visual Web Developer.
In the project I basically only need to use ASP.NET to read from a SQL 2005 database and write to JSON files.