Byte My Data

A personal collection of advice and solutions I've used.

About the author

Something about the author

Check for IsPostBack using javascript

I found this in an MSDN post.

You can't do it directly but if you add the following to the server side Page_Load in the code behind, you can check for the javascript variable on the client side.

server side:

        protected void Page_Load(object sender, EventArgs e)
        {
            // NOTE: the following uses an overload of RegisterClientScriptBlock()
            // that will surround our string with the needed script tags .
            ClientScript.RegisterClientScriptBlock(GetType(), "IsPostBack", string.Format("var isPostBack = {0};", (IsPostBack ? "true" : "false")), true);
        }

client side:

<head>
...
   
...
</head>
<body onload="doSomething();">

Categories: ASP.NET | C# | Javascript
Permalink | Comments (0) | Post RSSRSS comment feed

Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))

For some reason I started running into this error when I was trying to deploy a sharepoint webpart from visual studio. It just started happening out of the blue.

First I just rebooted the server and it deployed fine but when I made some changes to the code and tried to deploy it, the error came up again.

I found the answer here:http://social.msdn.microsoft.com/Forums/en/vsreportcontrols/thread/26accc30-9cfb-4d86-9c27-780f51929ecb

I had to add the ASP.NET account to each section.

  • Run dcomcnfg to bring up Component Services window.
  • Expand Component Services > Computers > My Computer > DCOM Config
  • Scroll down list, right click Windows Management and Instrumentation, and select properties.  A 5 tabbed window named Windows Management and Instrumentation Properties should be displayed.
  • Select the Security tab, then select radio buttons which activate the Edit... buttons.
  • Select the appropriate location and add the ASPNET account.
  • Reboot.
  •  


    Permalink | Comments (0) | Post RSSRSS comment feed

    Add a new line in a label control within a sharepoint webpart edit/config form

    I was creating a webpart and creating some custom edit values and I wanted to add a label for the dropdownlists I was adding.

    Adding the label before the dropdown was fine but I needed the dropdown on the next line. I tried using "<br/>" but that gave me an error when I tried to build it in visual studio.

    I tried System.Environment.NewLine but that didn't work and I tried "\n" with no luck and "\r\n" gave me an error when I tried to edit the webpart settings.

    I noticed that it seemed like the webpart error was being thrown whenever I had a slash combination in the text (i.e. "\r", "</...>") so I tried the non-html compliant "<br>" tag and that finally worked.

    Using this worked as well.

     myControl.Add(new LiteralControl("

    "))

    Categories: ASP.NET | SharePoint
    Permalink | Comments (0) | Post RSSRSS comment feed

    Getting "The password does not meet the password policy requirements" in Windows Server 2008 when creating new user

    If you don't want to force complex passwords change the various settings in the Password Policy by:

    1. Click Start -> Run and enter "gpedit.msc".
    2. Follow the menu tree from Computer Configuration -> Windows Settings -> Security Settings -> Account Policies -> Password Policies.
    3. Click on "Password must meet complexity requirement" and disable it.


    Permalink | Comments (0) | Post RSSRSS comment feed

    RadControls - javascript error telerik is undefined

    I'm using RadControls for AJAX Q1 2008 I got the 'telerik is undefined' javascript error on both IE7 and Firefox 3.5.3 and the way I fixed it was to replace the RadScriptManager I was using with the regular .NET ScriptManager.

    Apparently, in the latest versions of the RadScriptManager control (Q3 2009), there is an OutputCompression and setting it to false will solve the problem as well but I'm not able to test it; something you can try.


    Permalink | Comments (1) | Post RSSRSS comment feed

    Using SubSonic 3.0 in a VB.NET web application

    SubSonic is A Super High-fidelity Batman Utility Belt that works up your Data Access (using Linq in 3.0), throws in some much-needed utility functions, and generally speeds along your dev cycle. (http://subsonicproject.com)

    The SubSonic code is in C# and the examples say to drag the folder containing the DAL templates into your project. Now that's all fine and dandy for an example and if the project is in C# but what if it's in VB or you want to separate the DAL? The simple thing to do is:

    1. Add a new C# project to your existing solution.
    2. Place all the files in the Subsonic DAL template folder into the root project folder - don't put them in a sub-folder.
    3. Include only the *.ttinclude files into the project (leave the *.tt files excluded).
    4. Reference the SubSonic.Core.dll.
    5. Make your changes to the Web.config and Settings.ttinclude files.
    6. Delete the Default.aspx page (I didn't need it).
    7. Now include the *.tt files into the project and that should create the class files.
    8. Build this project only.
    9. Add a reference to this project in you VB.NET project.

    And that's it, you're all set.


    Tags:
    Categories: ASP.NET | C# | Databases | VB.NET
    Permalink | Comments (0) | Post RSSRSS comment feed

    Completely delete linux user

    Original page: http://linux.die.net/man/8/userdel

    Name
    userdel - delete a user account and related files

    Synopsis
    userdel [options] LOGIN

    Description
    The userdel command modifies the system account files, deleting all entries that refer to login_name. The named user must exist.

    Options
    The options which apply to the userdel command are:

    -f, --force
    This option forces the removal of the user, even if she is still logged in. It also forces userdel to remove the user's home directory or her mail spool, even if another user uses the same home directory or if the mail spool is not owned by the specified user. If USERGROUPS_ENAB is defined to yes in /etc/login.defs and if a group exists with the same name as the deleted user, then this group will be removed, even if it is still the primary group of another user.
    Note: This option is dangerous and may leave your system in an inconsistent state.

    -h, --help
    Display help message and exit.
    -r, --remove
    Files in the user's home directory will be removed along with the home directory itself and the user's mail spool. Files located in other file systems will have to be searched for and deleted manually.
    The mail spool is defined by the MAIL_DIR variable in the login.defs file.

    Files
    /etc/group

    Group account information.
    /etc/login.defs
    Shadow password suite configuration.
    /etc/passwd
    User account information.
    /etc/shadow
    Secure user account information.
    Exit Values
    The userdel command exits with the following values:

    0
    success

    1

    can't update password file

    2

    invalid command syntax

    6

    specified user doesn't exist

    8

    user currently logged in

    10

    can't update group file

    12

    can't remove home directory

    Caveats
    userdel will not allow you to remove an account if the user is currently logged in. You must kill any running processes which belong to an account that you are deleting.

    You may not remove any NIS attributes on a NIS client. This must be performed on the NIS server.

    If USERGROUPS_ENAB is defined to yes in /etc/login.defs, userdel will delete the group with the same name as the user. To avoid inconsistencies in the passwd and group databases, userdel will check that this group is not used as a primary group for another user, and will just warn without deleting the user otherwise. The -f option can force the deletion of this group.


    Categories: Linux
    Permalink | Comments (0) | Post RSSRSS comment feed

    Dovecot/Postfix problems with relaying, recieving and sending emails on an internal network

    Well, I setup a linux vm at work running Ubuntu with a static ip and an internal domain (devteam.grp) to use for our source control and PM web app (Subversion with Redmine).

    I also needed a mail server for sending and receiving mail for the devteam.grp domain. I wanted a mail server that could handle multiple domains yet have a simple installation; and the only thing that I fould was Citadel which was a very good but had way too many features for what I needed. Ubuntu has a package for it which made it easy to install but I ran into other issues afterwards.

    • I wasn't able to send to external domains from localhost.
    • I could only send mail to other local accounts from localhost.
    • I couldn't receive any emails from the company email accounts.

    I decided I didn't need to have the feature rich Citadel so I opted for the Dovecot/Postfix combination for pop3/imap and smtp. I ended up un/installing the pair a number of times over the last few days to figure out the problems through trial and error. A lot of the time was spent googling and some of the links that helped me in my search for a solution were:

    My fix was to:

    • Completely uninstall Dovecot and Postfix including configuration files.
    • Flushed the iptables (iptables -F) and allowed all access for now then configure it later.
    • Disabled the firewall (ufw - enabled it later and only allowed access to the required ports).
    • Made sure there was an MX record for the mail server.
    • I had to get the network admin to allow relays for the domain (devteam.grp) in MS Exchange.
    • Reinstall Dovecot from Synaptic Package Manager in Ubuntu (dovcot-common, dovecot-pop3d, dovcot-imapd and dovecot-postfix packages)
    • In the /etc/postfix/main.cf config file, I made sure that the "mydestination" parameter contained my domain name (devteam.grp) as well as the computer name (along with the other defaults). I also placed all the company domains in the "relay_domains" parameter.

    Here's my config:
    ##########################################################

    # See /usr/share/postfix/main.cf.dist for a commented, more complete version


    # Debian specific:  Specifying a file name will cause the first
    # line of that file to be used as the name.  The Debian default
    # is /etc/mailname.
    #myorigin = /etc/mailname

    smtpd_banner = $myhostname ESMTP $mail_name (Ubuntu)
    biff = no

    # appending .domain is the MUA's job.
    append_dot_mydomain = no

    # Uncomment the next line to generate "delayed mail" warnings
    #delay_warning_time = 4h

    readme_directory = no

    # TLS parameters
    smtpd_tls_cert_file = /etc/ssl/certs/ssl-mail.pem
    smtpd_tls_key_file = /etc/ssl/private/ssl-mail.key
    smtpd_use_tls = yes
    smtpd_tls_session_cache_database = btree:${data_directory}/smtpd_scache
    smtp_tls_session_cache_database = btree:${data_directory}/smtp_scache

    # See /usr/share/doc/postfix/TLS_README.gz in the postfix-doc package for
    # information on enabling SSL in the smtp client.

    myhostname = fcsbungaydevlinux
    alias_maps = hash:/etc/aliases
    alias_database = hash:/etc/aliases
    myorigin = /etc/mailname
    mydestination = devteam.grp, fcsbungaydevlinux, localhost.localdomain, localhost
    relayhost =
    relay_domains = $mydestination, company1.ca, company2.grp, company3.ca
    mynetworks = 127.0.0.0/8 [::ffff:127.0.0.0]/104 [::1]/128
    mailbox_size_limit = 0
    recipient_delimiter = +
    inet_interfaces = all
    home_mailbox = Maildir/
    smtpd_sasl_auth_enable = yes
    smtpd_sasl_type = dovecot
    smtpd_sasl_path = private/dovecot-auth
    smtpd_sasl_authenticated_header = yes
    smtpd_sasl_security_options = noanonymous
    smtpd_sasl_local_domain = $myhostname
    broken_sasl_auth_clients = yes
    smtpd_recipient_restrictions = reject_unknown_sender_domain, reject_unknown_recipient_domain, reject_unauth_pipelining, permit_mynetworks, permit_sasl_authenticated, reject_unauth_destination
    smtpd_sender_restrictions = reject_unknown_sender_domain
    mailbox_command = /usr/lib/dovecot/deliver -c /etc/dovecot/dovecot-postfix.conf -n -m "${EXTENSION}"
    smtp_use_tls = yes
    smtpd_tls_received_header = yes
    smtpd_tls_mandatory_protocols = SSLv3, TLSv1
    smtpd_tls_mandatory_ciphers = medium
    smtpd_tls_auth_only = yes
    tls_random_source = dev:/dev/urandom
    ########################################################## 

    In the /etc/dovecot/dovecot-postfix.conf file, I set the "protocols" to "pop3 imap" and the "disable_plaintext_auth" to "no". I didn't make any other changes.

     

    It seems like such a quick thing to setup now that I write down my process but it took a while to figure out what needed to be done in the first place LOL

    The only problem I'm having right now is that mail I send from my company email on the network to devteam.grp is returned undeliveralbe:

     

    This message was created automatically by the SMTP relay on mail.company1.ca.

     

    A message that you sent could not be delivered to all of its recipients.

    The following address(es) failed:

     

      santosh@devteam.grp

        Unrouteable address

     

    Strange thing is that another company domain on the network don't have this problem.  Well it's not quite that strange; we've got multiple MS Exchange servers setup for the various company domains and it's probable that the relaying on exchange server for company1.ca hasn't been configured.

    I think RC's (one of our network admins) going to get sick of all my emails Laughing


    Permalink | Comments (0) | Post RSSRSS comment feed

    Datasets in App_Code folder not being recognized after converting website project to web application.

    I was getting "Type 'TeamStats.TeamStatsDataTable' is not defined" and "Type 'TeamStatsTableAdapters.TeamStatsTableAdapter' is not defined" errors in my code.

    In my case it was the datasets but it could be for any code file you have stored in the App_Code folder in a website project.

    The App_Code folder isn't recognized as an ASP.NET folder in a web application project so you'll have to move the files from there into another location in your project.

    I moved the *.xsd and *.xss dataset files into a new folder and then right-clicked on the folder in Visual Studio and selected "Include In Project" which generated the *.Designer.* files for the datasets.


    Categories: ASP.NET
    Permalink | Comments (1) | Post RSSRSS comment feed

    Welcome to Byte My Data

    The blog is in part an archive of sorts for all the solutions I found for all the programming (or other) issues I have run into.

    Whenever I run into a problem, I go off and Google the solution but the solution isn't always reachable that easily. Like everyone, I sometimes wade through the post of one person's issue which is sort of related to my problem to get to a comment of a person who gives a link to a solution for something that's closer to what I'm experiencing AND then check out the comments on that post to maybe use that solution or discover my own from all the information Wink

    Please remember that the majority of solutions will be snippits from other pages and/or links to the original page and are not my own; whenever possible the original link is included. Hopefully you might find some solution here for something that's been boggling you and I encourage you to visit the original links for the complete articles and their comments. You never know, it could be the one link that solves your issue  Smile

    Santosh


    Tags:
    Categories: General
    Permalink | Comments (0) | Post RSSRSS comment feed