This most common reasons for inappropriate elimination tend to be from an injury to the penis, from the reproductive tract, prostrate or from the urinary tract. Blood in the urine can be caused urinary stones, Cystitis, Kidney Disease, Bladder Cancer, or Urinary Bacterial Infections. Urinary Stones are common and found in the kidneys, bladder and urethra though usually they are in the bladder. The formation of crystals or stones in urinary tract can be caused by the following factors usually working together: mineral crystals in the urine, bacteria, diseases, some medications, excess Vitamin C, imbalance in pH of urine. Typical symptoms are straining to urinate, frequent urination of small amounts and blood in the urine. Some breeds are known to have problems with stones. These are Miniature Schnauzer, Schnauzer, Lhasa Apso, Shih Tzu, Bichon Frise, Miniature poodle, and Yorkshire terrier. Cystitis is when your dog's bladder becomes inflamed. It is believed that infections, polyps, tumors and stones contribute to this condition, but the actual cause is unclear. Typical symptoms are straining to urinate, frequent urination, straining to urinate, difficulty urinating and blood in the urine. Kidney Disease is a common cause of non-accidental death in dogs. It is not clear what causes kidney disease but it is believed that dehydration, blood loss, impaired heart function, tumors, infections and toxins contribute to it. Some medications for kidney disease may cause blood in the urine. Bladder cancer occurs in middle-aged and older dogs. Bladder cancer is not as common as other causes such as Urinary tract infections, though it is not recognized early for that same reason. Typical symptoms are frequent urination, urinating small amounts, blood in the urine, and infections. Urinary bacterial infections can occur in bladder (most common), kidneys, urethra, and prostate. They are easily treated once diagnosed. They are the major cause of the prostate disease in male dogs. The prostate becomes inhabited by bacterial and it becomes difficult to eliminate. Some other conditions such as diabetes, cancer and viral diseases affect a dog's immune system and may contribute to this condition.
The best thing to do is to get your pup in to see a vet as soon as you can. Some of the possibilities for what is going on can end up being very painful or life threatening if left untreated.
I hope this helps!!
If he's able to hold the urine and feces when he feels like it, then I'd begin thinking it was behavioral.
However, before you can assume that's the issue, he should be seen by his regular vet, just to rule out any possible medical causes.