asp.net

exception (ab)use in web development

I find myself using exception in web development even for conditions that are not really errors, let alone exceptional ones - just logic decisions, validations... in a web page, I often write code like so: try { int id; if(!int.TryParse(txtID.Text, out id)) throw new Exception("ID must be an integer"); if(IdAlreadyExi...

How to bind a classes property to a TextBox?

I have a Customer class with a string property comments and I am trying to bind it like this: <asp:TextBox ID="txtComments" runat="server" TextMode="MultiLine" Text=<%=customer.Comments %>> </asp:TextBox> However, it gives me the error: Server tags cannot contain <% ... %> constructs. I also have a method...

add filter row to gridview

I want to add a row to that will contain dropdowns,search textboxes, and maybe other controls to allow filtering to the gridview. I've looked at This Question but it did not help me. How can I add a row so i can add these controls to my gridview? Protected Sub GridView1_RowDataBound(ByVal sender As Object, ByVal e As System.Web.UI.WebCo...

Maintain scroll position of a div within a page on postback

I have a div within an aspx page with overflow set to auto. The contents of the div are dynamically created and consists of a list of link buttons. <div id="div1" style="overflow: auto; height: 100%;"> ..... </div> When I scoll down in the div and click on any of the link buttons, the page reload loses the scroll position inside the ...

Umbraco: List Child Nodes in User Control

I have a user control in which I need to return child nodes based on parentID. I am able to get the parentID, but don't know the syntax for returning child nodes. ...

How come the gridView Page is not inserting or updating or refreshing. What am I doing wrong?

How come the gridView Page is not inserting or updating or refreshing. What am I doing wrong? protected void DetailsView1_ItemInserting(object sender, DetailsViewInsertEventArgs e) { using (SqlConnection cn = new SqlConnection(Utilities.ConnectionString())) using (SqlCommand cmd = new SqlCommand("uspUpdateDisplayHours", cn)) ...

ASP.NET: change link to static asset dynamically

Hi all, We are building a internal static asset server. Each environment (dev, staging, prod) has its own asset server, and the asset is reference throughout the web application (html, aspx, ascx, css, javascript, etc...) To reference the correct asset server in the correct environment, one solution is to write a http module to interc...

How to save user entered data to session state from a dynamically created control?

using c# (asp.net) i'm programmatically creating several drop down lists (random number). the user selects a particular value from each list and i need to save the user selected value. if i try to save the data to session state by using a button click event it says the drop down list object hasn't been created. (obviously cuz i'm creat...

LINQ to SQL - How to select specific columns and return strongly typed list

I'm trying to use LINQ to SQL to select a few specific columns from a table and return the result as a strongly typed list of objects. For Example: var result = (from a in DataContext.Persons where a.Age > 18 select new Person { ...

ASP.Net: Page_Load() being called multiple times

Hi, I don't know alot about ASP.Net but I'm trying to make a new control for a message box. You enter some info and press a button. However, for some bizarre reason when the button is pressed, Page_Load() gets called a second time, and all of the member variables are reset to null! I need those variables, and Page_Load() has not reason...

Concatenating record values in database (MS Access) or in server side code (ASP.NET)

Hi, sorry to bother you people again. I've searched all over the internet but I can't find the solution to my problem. I have two tables in Access and the output is like this: MATH 5 ENGLISH 3 ENGLISH 2 PHYSICS 5 MATH 1 MATH 3 I want it to be: MATH 5, 1, 3 ENGLISH 3, 2 PHYSICS 5 How can I accomplish this? It tried playing with S...

respond with 404 error from asp.net page codebehind

I have a scenario in which I'm serving a file from codebehind. which file, depends on request. in some cases there will be no file to serve and I want to return 404 to the browser. how can I do that from codebehind? is this the correct course of action to show user there's no file available? ...

Finding all Controls on a Page

If I start with Page.Controls Then recursively call all the children control.Controls, will the guarantee that I find all the controls that exist on a given page. Are there any time that orphaned controls can exist, or any other controls that will not show up when iterating through the page's controls in this way? Even if this is co...

Get absolute url for a file in my asp.net project to include HTTP// etc for use externally?

Hi there, been playing around with ResolveClientUrl("~/Confirmation.aspx") and other methods.. I am tryin go get the FULL absolute URL of the page including Http: etc etc.. Anyone knows how to do this? thanks ...

LinkButton.Command in user control (ascx) will not call specified method

I have the following code: public partial class queryTerm : System.Web.UI.UserControl { private static readonly List<string> BooleanOperators = new List<string> { ".", "AND", "AND NOT", "OR", "OR NOT" }; protected void BuildBoolPanel() { var parensOpen = _labelBoolean.Text; foreach...

How to start new ASP.NET Web Application using C#

I'm trying to start a new ASP.NET Web Application Project using Visual Studio 2008. The default language is somehow VB and I want C#... I cannot for the life of me figure out how to change it to C#. I've gotta be missing something somewhere.... thanks! ...

Execute script once for a page

I have added the following script to my asp.net master page $(function() { $("#someDiv").someMethod(900, { chars: /\s/, doit: [" ( <a href='#' onclick='window.location.reload(true);' class='truncate_show'>more</a> . . . )", " ( . . . <a href='#' class='truncate_hide'>less</a> )"] }); ...

How to control ASP.NET ModalPopupExtender after AsyncPostBackError

Hi there, I have a pretty simple question which I'm sure somebody has come across before. I am using an AJAX ModalPopupExtender to initiate an Ajax request. In the event of an error I want to raise an alert and hide the Ajax ModalPopupExtender. My attempts of hiding the ModalPopup extender and displaying the exception as an alert have...

Three asp.net question

Hello everybody. All my questions in this topic related to asp.net 2.0 While working on some old project when i first opened it Visual studio asked me if i want to convert project from asp.net 2.0 to asp.net 3.5. Is it safe to chose yes ? If i chosen no in the previous question, how can i later still convert it to asp.net 3.5 ? (Visual...

x264 process stops working no matter on anything

Hi, i have made my video encoder. well very simple one and my process stops working after it gets to certain percent. Is there anything i could do to make it work? Is there some memory limitation? Could i run it somehow different? ...