asp.net

How to Html.Encode in webforms

Hi, I have a webforms applications. There is a page with textboxes and users enters search terms into these which are used to query the database. I understand I need to prevent javascript injection attacks? How do I do this? In MVC I would use Html.Encode. It doesn't seem to be recognising it here. Thanks! ...

How do you integrate Classic ASP with ASP.NET application?

I have an old Classic ASP application. Now the users wants to have some enhancements on it. I have no working experience in Classic ASP. I want to do the enhancement in ASP.NET which i am very fluent. Can i do it? All i wanted is provide a link in ASP page and once the user clicks on that link, i want to open an ASPX page as a popup win...

Regular expression behaving different on in c# code behind and on aspx

Note: question has been edited to stay in sync with what I have tried from the commenters I am trying to match an email, however when put the same expression in the code behind, vs the aspx, I seem to be getting different matches for email address. The aspx regex validator seems to be working correctly, however I need to validate for my...

Adjust DIV height and width to actual size of Silverlight control

Hello, I want to embed a silverlight app into a web page and have the height/width of the div that contains the silverlight control match the dimensions of the actual size of the silverlight control. I essentially want the div to stretch to accommodate the size of the silverlight control. I do not know what size the silverlight contro...

How to get Page assembly from a Control?

I've create a method that gets the current page's assembly name and version so that I can display it in the page footer. It works just fine, but I'd like to move this logic into a control that I could drop into any web application project master page that references my control library. However, in the control library Assembly.GetExecutin...

How to get all windows groups?

I wrote this to get the groups a particular user belongs to: DirectoryEntry AD = new DirectoryEntry("WinNT://" + Environment.MachineName + ",computer"); DirectoryEntry user = AD.Children.Find(completeUserName, "user"); object obGroups = AD.Invoke("Groups"); foreach (object ob in (IEnumerable)obGroups) { // Create object for each grou...

Does the ListBox SelectedIndexChanged event require postback in ASP.NET?

I'm trying to add a JavaScript function to show all selected items from a ListBox as concatentated strings in a Label on the page. It's needed because AutoPostBack="true" will cause the ListBox to scroll all the way back to the first selected item. So this code works: <script type="text/javascript"> function Updatelist() { ...

Is it possible to read the content of a content place holder from the masterpage?

We would like to use a contentPlaceHolder in our pages to set titles. What we would like to do is have the masterpage check the contentPlaceHolder to see if it has content in it. This way we can set up an e-mailer that will tell us what pages that don't have page titles since we have a fairly large site. We also have nested masterpage...

_Setting_ textbox's text using FindControl

Hi all, I need to be able to set a textbox's (which is inside a gridview row) text to a certain string in runtime. I have used FindControl before, but can't figure out the syntax for actually setting the value of the textbox rather than just getting. Here's what I have, which doesn't compile: ((TextBox)e.Row.FindControl("txtPath")).Text...

how to convert powerpoint into images

I want to convert powerpoint into images when a user uploads it to my server. What is the best way of doing it? I was using interop, but it seems to be working only on client side. ...

ASP.net Jquery ajax autocomplete data

Hey, Is it possible to change the "data source"- the autocomplete from this jquery code: $(".textbox").autocomplete( "**autocomplete.php**", { delay: 10, minChars: 2, matchSubset: 1, matchContains: 1, cacheLength: 10, onItemSelect: selectItem, onFindValue: findValue, formatItem: formatItem, autoFill:...

JQuery Validate Plugin MS MVC: Won't validate

I'm trying out the jQuery Validation plugin jQuery Docs Here is the markup of my form: <% using (Html.BeginForm("action", "contoller", null, FormMethod.Post, new { id = "sxform" })){%> <div id="manifest"> Manifest Option:<br /> <%= Html.DropDownList("docid", ViewData["manifests"] as SelectList, new { @class = "requi...

Efficiently removing naughty words from users comments

I have an ASP.NET app that accepts users comments and them in a SQL database. I want to make sure that I weed out any "naughty" words so I can keep my app respectable. Problem is that I'm finding there are LOTS of these words. ;> My question is, what's the most efficient way to do this processing? Should I have a table in SQL and wri...

Is HttpPostedFile.ContentType a flawless way to validate an uploaded file?

I want to validate the file type to make sure the user is uploading an image of type JPEG, GIF, or PNG. Instead of checking the file extension, I figured using HttpPostedFile.ContentType would be safer since it checks the MIME content type. protected void cvValidateImageType_ServerValidate(object source, ServerValidateEventArgs args) { ...

Carriage Return (ASCII chr 13) is missing from textbox postback values when used within an ASP.NET Update panel

I have an ASP.NET TextBox with TextMode = TextBoxMode.MultiLine that is used within an AJAX Update Panel. The .Text value has been pre-set to a value that has multiple lines. When using Chrome(7.0.517.41) or Firefox(3.6.11) working with the controls posted back value on the server the carriage return is lost if the user hasn't edited th...

How do I programmatically define my own X-Header field in an email?

I working with an app that sends emails out to a predefined list of subscribers. Should an email bounce, I think the email is sent back to the email address specified in the "Return-path" header property, but I need to uniquely identify who sent this email(diff users can log into this app). So, I thought I would specify my own X-Header/X...

ASP.NET ReportViewer Server Report Render Stream results in exception

I'm trying to use the ServerReport.RenderStream method from the ASP.NET ReportViewer (2008 SP1), but I'm getting a rsStreamNotFound exception from the method. I've tried the two different lines of code below after setting the parameters. I'm interfacing with SQL Server 2005 and SSRS 2005. I've seen articles about a hotfix for this issue,...

Handling files uploaded with a size greater than maxRequestLength in web.config

In my web.config, I have the file upload size limited to 10 MB: <httpRuntime maxRequestLength="10000" /> <!-- file size limit in KB --> On my page, I'm checking to see that the user doesn't upload a file larger than 5 MB: protected void cvImageSize_ServerValidate(object source, ServerValidateEventArgs args) { args.IsValid = (fupF...

put All jquery Scripts in master page.

Hi. i am using jquery and jquery ui plugins in my web application. and i have some asp.net server controls that they register their scripts on the page. Since my application should be work Local could i put all scripts in master page ? all scripts i mean jquery script and jquery Ui scripts such as DatePicker Dialog and effects. or is the...

HTML email "opens" not being tracked

Update This question has gotten off on the wrong foot. Let me pose the question as follows: Let's say I wanted to show my StackOverflow "flair" badge in the signature of an email in Outlook. Obviously, I would want the image to be refreshed whenever I reply to an email or forward the email. Now, assuming the I (and others) have deci...