Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
M

Mark Graham

@Mark Graham
About
Posts
20
Topics
1
Shares
0
Groups
0
Followers
0
Following
0

Posts

Recent Best Controversial

  • PostBackUrl
    M Mark Graham

    The Postback url defaults to the current page and this is where your first click will return to, because, at this first click point your browser doesn't know to postback to NewPage.aspx. Only on the second click (after you've set Button1.PostBackUrl = "NewPage.aspx") will you get postback to the new page. IF YOU NEED TO POSTBACK TO A DIFFERENT PAGE THEN.... you can't avoid using javascript. Setting PostBackUrl on the server won't affect the current request (your first click). IF YOU'RE NOT REALLY CONCERNED WITH POSTBACK THEN.... do what the other guys suggested and replace the Button1.PostBackUrl = "NewPage.aspx" with the ReDirect, or Server.Transfer("NewPage.aspx"); code.

    Mark Graham (MCP) blogging about Design Patterns, C#, Asp.Net, CSS, Javascript and Ajax at: DESIGN CODE TEST[^]

    ASP.NET help csharp javascript tutorial question

  • PostBackUrl
    M Mark Graham

    I think he wants to "Postback" to a new page and not re-direct to a new page.

    Mark Graham (MCP) blogging about Design Patterns, C#, Asp.Net, CSS, Javascript and Ajax at: DESIGN CODE TEST[^]

    ASP.NET help csharp javascript tutorial question

  • AJAX control Toolkit Accordion Control problem
    M Mark Graham

    Here's a sample that works for me. This is one of my accordian snippets from an Ajax-enabled web project. Take a look - you might see something that you have missed. Also, check your CSS - make sure you don't have bugs in there - something that might be hiding a div for example. <ajaxToolkit:Accordion ID="ajax_acc_Reports" runat="server" HeaderCssClass="accordionheader" HeaderSelectedCssClass="accordionheader-selected" SelectedIndex="-1" AutoSize="None" FadeTransitions="true" TransitionDuration="250" FramesPerSecond="40" RequireOpenedPane="false" SuppressHeaderPostbacks="true"> <Panes> <ajaxToolkit:AccordionPane ID="apnAnalysis" runat="server" ContentCssClass="accordionpane-selected"> <Header><strong>Analysis</strong></Header> <Content> <ul><li><a href="Reports/Analysis/July_09.pdf" title="QA July 09 Report" target="_blank">QA July 09 Report</a></li></ul> </Content> </ajaxToolkit:AccordionPane> </Panes> </ajaxToolkit:Accordion> Please let me know if this does or does not help you

    Mark Graham (MCP) blogging about Design Patterns, C#, Asp.Net, CSS, Javascript and Ajax at: DESIGN CODE TEST[^]

    ASP.NET sysadmin help

  • ASP.NET Provider and DAL
    M Mark Graham

    DALs are still very popular and play a big role in n-Tier design. It's all about seperation of concerns/code maintenance: Your GUI code and your business logic code don't need to understand the database; they don't need to understand SQL, so abstract this kind of code. There are some really useful, really cool things in .Net but in my opinion, a few of them ignore good practice - putting connectionStrings in the application is one of them. However, it does depend on how scalable your application needs to be. If your app. consists of a couple of forms for a HR dept to add new staff, and isn't likely to grow much then I'd say...yeah...go with .Net Membership and don't concern yourself too much about design patterns, stick your db properties in the app.config/web.config. It's all about context really. What kind of application are you working on? Is this a team project or is it an app you're doing on your own? I'll see if I can find some detailed articles for you.

    Mark Graham (MCP) blogging about Design Patterns, C#, Asp.Net, CSS, Javascript and Ajax at: DESIGN CODE TEST[^]

    ASP.NET csharp question asp-net database help

  • Call Stored Procedure Using C#
    M Mark Graham

    Here's a helper class I use. It's lightweight but contains a few useful methods. Create a new class in your project and call it 'DbAssist' and copy this code in there. I haven't documented the methods so if you have trouble understanding anything just reply and I will assist. Cheers

    using System;
    using System.Configuration;
    using System.Data;

    namespace Common.Data {

    public static class DbAssist {
    
        private static void CheckConnectionClosed(IDbConnection connection) {
            if (connection.State != ConnectionState.Closed) {
                throw new InvalidOperationException("An error has occurred: connection is not in closed state.");
            }
        }
    
        // Connection help
    
        public static string GetConnectionString(string key) {
            try {
                return ConfigurationManager.ConnectionStrings\[key\].ConnectionString;
            } catch (NullReferenceException ex) {
                throw new ConfigurationErrorsException("An error has occurred: "
                    + key + " does not exist in config.", ex);
            }
        }
    
        // Scalar help
    
        public static object ExecScalar(string sqlText, IDbConnection connection) {
            return ExecScalar(sqlText, connection, CommandType.Text);
        }
    
        public static object ExecScalar(string sqlText, IDbConnection connection, CommandType cmdType) {
            return ExecScalar(sqlText, connection, cmdType, null);
        }
    
        public static object ExecScalar(string sqlText, IDbConnection connection,
                CommandType cmdType, IDataParameter\[\] parameters) {
            CheckConnectionClosed(connection);
            using (connection) {
                connection.Open();
                IDbCommand command = connection.CreateCommand();
                command.CommandText = sqlText;
                command.CommandType = CommandType.StoredProcedure;
                if (parameters != null) {
                    foreach (IDataParameter p in parameters) {
                        command.Parameters.Add(p);
                    }
                }
                return command.ExecuteScalar();
            }
        }
    
        // IDataReader help
    
        public static IDataReader ExecReader(string sqlText, IDbConnection connection) {
            return ExecReader(sqlText, connection, CommandBehavior.CloseConnection);
        }
    
        public static IDataReader ExecReader(string sqlText, IDbConnection connection,
    
    C# csharp database help

  • ASP.NET Provider and DAL
    M Mark Graham

    You're trying to keep seperation of concerns, as you should. The problem is, Asp.Net web applications are very much dependant on app and web.configs, which don't run in class libraries. I don't use .Net Memberships. I created my own role-based security model (did this before I started using .Net) and created data providers to go with it. Also, I use a ConnectionProviderFactory (returns an IDbConnection) class to maintain connection strings so my Dals can be completely independant from the applications using them. There are some useful features provided in .Net but if you require more abstraction and extensibility you sometimes need to break-out a little.

    Mark Graham (MCP) blogging about Design Patterns, C#, Asp.Net, CSS, Javascript and Ajax at: DESIGN CODE TEST[^]

    ASP.NET csharp question asp-net database help

  • Problem with Ajax Modal pop up
    M Mark Graham

    Have you deployed the Ajax toolkit library to the server?

    Mark Graham (MCP) blogging about Design Patterns, C#, Asp.Net, CSS, Javascript and Ajax at: DESIGN CODE TEST[^]

    ASP.NET help sysadmin

  • Loading image into WebPage...
    M Mark Graham

    It's also worth pointing out that if you decide to use plain old html instead of an asp:Image then you should drop the tilde(~) Mark Graham (MCP) blogging about Design Patterns, C#, Asp.Net, CSS, Javascript and Ajax at: DESIGN CODE TEST[^]

    ASP.NET sysadmin help question

  • Caching not working
    M Mark Graham

    I only ever access the cache item like: object sessionObj = HttpRuntime.Cache[key]; 'Get' sounds like it would do the same but I'm not certain.

    Mark Graham (MCP) // The Doodler blogging about C#, Asp.Net, and Design Patterns at: codeArch[^] and contributing at dotNet Notepad[^]

    ASP.NET help question

  • Will setting static machineKey resolve FormsAuthentication issue in web farm??
    M Mark Graham

    My site is hosted on a shared server that is load balanced in web farm. I don't have access to IIS, machine config files, or anything that isn't directly related to my FTP space and my Sql Server(and that's limited). My Problem I now want to introduce an authentication process in to the site. I already have my own 'CreateAccount' and 'SignIn' asp.net pages(not using Asp.Net provided controls), and I want to use them with FormsAuthentication class. I want to know if adding static keys to machineKey section in MY SITE'S web.config (not machine web.configs) will resolve any potential issues with decrypted authentication cookies in web farm. I'm not familiar with the set up of farms but presumeably my site will be copied to several servers - all using the same web.config(my web.config) Hope I've made myself clear. Please ask me a question if you aren't sure of anything... Thanks for your time.... Mark

    Mark Graham (MCP) // The Doodler blogging about C#, Asp.Net, and Design Patterns at: codeArch[^] and contributing at dotNet Notepad[^]

    ASP.NET csharp help question asp-net database

  • design pattern
    M Mark Graham

    Design Patterns are solutions to common programming problems and the term "Design Pattern" is used to describe various common solutions. A good C coded book is Design Patterns: Elements of Reusable Object-Oriented Software[^]. Also, I'm currently writing some articles about design patterns and providing some good practical examples, however, these are in C# (you won't have problems understanding C# syntax if you're familiar with C and C++). My first is about Implementing the State Design Pattern[^]. I will be writing a lot more of these. Hope you can visit and please feel free to comment or ask questions.

    Mark Graham (MCP) // The Doodler blogging about C#, Asp.Net, and Design Patterns at: csCoffee[^] and contributing at dotNet Notepad[^]

    C / C++ / MFC c++ design regex architecture

  • patterns and practices
    M Mark Graham

    Patterns are great for solving common problems. The only problem is a lot of the examples accompanying design pattern publications don't appear to be common problems in my eyes. I am writing some articles about design patterns at the mo. and I'm going to provide practical examples. My first article is about the Implementing The State Software Design Pattern[^]. I will be writing many more!! When I have a few Design Pattern articles in my blog I will create a new 'Design Patterns' header for them so they are easier to find. Hope my blog will assist you. Ps. Also, do a google for Extract Method, Extract Parameter. These are a couple of basic patterns that can be applied to code straight away.

    Mark Graham (MCP) // The Doodler blogging about C#, Asp.Net, and Design Patterns at: csCoffee[^] and contributing at dotNet Notepad[^]

    .NET (Core and Framework) csharp architecture tutorial question

  • Update command?
    M Mark Graham

    do you mean....Can you execute an Update statement (against a supporting sql database) from a C# application?

    Mark Graham (MCP) // The Doodler blogging about C#, Asp.Net, and Design Patterns at: csCoffee[^] and contributing at dotNet Notepad[^]

    ASP.NET csharp question announcement

  • clear the textbox on click os submit button in update panel
    M Mark Graham

    Hi, sorry, could you just clarify.... You have a web form and it has 1) An update panel 2) A TextBox outside the UpdatePanel 3) A Button inside the UpdatePanel then you want to 1) User to type in text box 2) User to click the Button 3) Button to submit request - Panel to update 4) Textbox to clear after all this has taken place

    Mark Graham (MCP) // The Doodler blogging about C#, Asp.Net, and Design Patterns at: csCoffee[^] and contributing at dotNet Notepad[^]

    ASP.NET help announcement

  • Business Objects
    M Mark Graham

    Hi there, I may as well chuck something in here, as I love design... It's difficult to decide what to go with sometimes. I mean, there are so many methodologies and one developer will claim this way is better, another will claim that way, etc. etc. It sounds to me like you have a relatively uncomplicated problem with not a huge amount of workflow and service requirements (please correct me if I'm wrong). It sounds like you might be implementing a reasonably straight-foreword windows app or web site. WINDOWS or WEB - two completely different technologies here!! Stateful and stateless. Nobody can truely answer you query without understanding more about your problem. However, I've implemented Active Record when business logic isn't too complex (you won't require the dreaded ORM's you speak of) and it has been very successful for me. I have also mixed some Active Record patterns with unrelational Domain Patterns as business complexity has increased - this has also worked. I read the other answers Don't confuse DTO's with Business Objects. DTO's just hold data(fields) and don't implement behavior, but Business objects do implement behavior and usually have a method to persist itself, by implementing a Save method, and calling through to a data layer/tier. Developers like to give advise but do your own research and when you've decided your route - implement it properly, that's my advise. I'm going on a bit aren't I :) I've recently created a couple of blogs and I've already written an article about the Active Record Pattern[^] (I've turned it in to a Domain Record Pattern) and I'm going to be writing a lot more about design. It's interesting to see what kind of questions people are asking. I hope you get chance to look at my blog - and please comment!!! Here's a recommended read for you. Microsoft .NET: Architecting Applications for the Enterprise[^] and it's not too heavy either. The article I've posted on dotnet-notepad are just notes (the blog is literally a notepad of ideas). My in-depth articles are going on

    C# database business sales tutorial question

  • retrieving a sql results with a specific Id using Rank and Partition
    M Mark Graham

    What springs to mind.... The first thing I would look at is returning two result sets (presumably your first would have one row in it and your second would have many, excluding the unique row you've already selected, ordered by create date) from your store proc. Then using a ADO.Net DataReader I would merge the two result sets in code. Here's some pseudo with some c#

    // create return object (a list) here
    
    using ( SqlDataReader reader = command.ExecuteReader( ) )
    {
        // read first doc
    
        if ( reader.Read( ) )
        {
            // add data to a DTO, or business object then add to results list
        }
    
        // move to next result set and read the other docs
    
        **reader.NextResult();**
    
        while ( reader.Read( ) )
        {
            // add data to a DTO, or business object then add to results list
        }
    }
    // return list - the merged results
    

    This is still only one stored proc call; one trip across the wire (not that two trips in this case would make the slightest bit of difference). Has this helped?

    Mark Graham (MCP) // The Doodler blogging about C#, Asp.Net, and Design Patterns at: csCoffee[^] and contributing at dotNet Notepad[^]

    ASP.NET database help

  • Add control in UpdatePanel
    M Mark Graham

    So, am I right in saying that your button is doing a postback and your page is reloading(no ajax)? If this is the case then I think it's the Triggers section of the UpdatePanel that you're missing. See my sample code below (you can ignore the content, it's just a report I knocked up). I've made bold and italic the Triggers section I think you could be missing. Also, the code where your dynamic control will be added will have to go in the ContentTemplate section of your UpdatePanel. My apologies if I've missed the point and you're already doing this.

    <asp:Button ID="btnRun\_TopHopFaults" runat="server" Text="Run Report"
        OnClick="btnRun\_TopHopFaults\_Click" />
    <asp:UpdatePanel id="pnlTopHopFaultsResults" runat="server" UpdateMode="Conditional">        
        _**<Triggers>
            <asp:AsyncPostBackTrigger ControlID="btnRun\_TopHopFaults" />
        </Triggers>**_
        <ContentTemplate>                        
            <asp:Repeater ID="repTopHopFaults" runat="server">
                <HeaderTemplate>
                    <table>
                        <tr>
                            <th></th>
                            <th>Guidance Ref</th>
                            <th>Guidance</th>
                            <th>Quantity</th>
                        </tr>
                </HeaderTemplate>
                <ItemTemplate>
                        <tr>
                            <td><%#DataBinder.Eval(Container.DataItem, "Position") %></td>
                            <td><a href='<%#string.Concat("javascript:showHopDrillDown(", DataBinder.Eval(Container.DataItem, "ID"), ")")%>'>
                                <%#DataBinder.Eval(Container.DataItem, "FieldRef") %>
                                </a>                                                    
                            </td>
                            <td><%#DataBinder.Eval(Container.DataItem, "Field") %></td>
                            <td><%#DataBinder.Eval(Container.DataItem, "FaultCount") %></td>
                        </tr>                            
                </ItemTemplate>
                <FooterTemplate>
                    </table>
                </FooterTemplate>
            </asp:Repeater>
    
    ASP.NET question

  • problem in transaction .
    M Mark Graham

    I've never had to deal with transactions across two different providers (oracle and sql server) before but here's something off the cuff. How about adding some kind of 'Pending' state to the inserts 1. Perform first insert (pending) 2. Perform second insert (pending) 3. Validate both have inserted 4. Update first (live) 5. Update second (live) I know there's still a window for something to fail between operations 4 and 5 but it's much less likely than a failure between 1 and 2 (due to constraints you might have on various fields). A Transaction would be better but this is an option.

    Mark Graham (MCP) // The Doodler blogging at: dotnet notepad

    ASP.NET database oracle help

  • getting textbox text from client back to server side
    M Mark Graham

    Firstly, check that EnableViewState hasn't been set to false on your text box. It's true by default so it will only be false if you or another programmer has added: EnableViewState="false"

    Mark Graham (MCP) // The Doodler blogging at: dotnet notepad

    ASP.NET javascript html com sysadmin help

  • Modal popup
    M Mark Graham

    just to back up the previous response - you implement it the same way you'd implement it if you wasn't using the modal popup. Presumably your button is an asp:Button so create your event handler (if you don't know how to write it manually then just double click it in your IDE designer) and add your code. When the button is clicked by a user it will cause a postback and your code will execute. Have you managed to get your modal box popping up ok?

    Mark Graham (MCP) // The Doodler blogging at: dotnet notepad

    ASP.NET design tutorial
  • Login

  • Don't have an account? Register

  • Login or register to search.
  • First post
    Last post
0
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups