This blog is for all Microsoft & .net lovers who may find themselves in need of help or information once in a while. We all have questions and we all need to know more than we know right now. When I come across things that I think may be useful, I post it. When I have something to say that I think is important, which is everything, I post it. All of my C#, ASP.NET, VB, AJAX & programming friends around the world are welcome to the info in my blog - Ramblings Of A Crazy DotNet Woman!
Wednesday, December 12, 2007
PureBlogic Has Been Taking Up My Time! :-(
I've been working on this for some time. It has been a big deal for me for a couple of reasons. First, I taught myself PHP to support this project. Before you even say it, I know. I know. I'm dot net crazy right? So what am I doing cheating with PHP? Well there are a number of reasons. I really wanted to use Wordpress for this blog because of it's superior support and because of all the fantastic plug-ins that are available for the platform. I wish I could have that kind of platform in .NET. I started thinking about creating a platform written in C#.NET that would be as great as Wordpress. I wanted to leverage my .NET knowledge. Then common sense got into me and I decided to just spend a little time teaching myself PHP. Second, I got to use MySQL. I love MySQL. I'm SQL Server certified and all, but MySQL is free for everyone. I think that opensource projects tend to become great because everyone works to make them the best they can be. MySQL has a lot of support everywhere. SQL Server is my database of choice, but I enjoyed being able to use my MySQL knowledge.
I'm not PHP crazy, but, I have to admit that it is pretty simple. There are a lot of positives to the language. Am I going to switch to the DARK SIDE? Nope. Well..... not until I start developing Wordpress themes :-). At that point, I am going to be one with the DARK SIDE. Sometimes the DARK SIDE pays the bills. I also did something else that I didn't plan on doing - using the Linux OS. I've truly gone over the edge !!!! But don't worry. I'm still dot net crazy and I'm still on the right team.
Sometimes you just have to learn what you need to learn to get done what you need to get done!
Check out my blog at www.PureBlogic.com when you have a chance and let me know what you think. Don't concentrate on the design. Its in flux right now while I create exactly what I want.Due to fact that I needed to put posts on the blog before I could qualify for certain programs, I had to put it up even without the exact look on it that I wanted. It will change real soon. In the interim, I'll be back!
Wednesday, November 21, 2007
Getting Information From input Tags On A Page In .NET Using Request.Form.AllKeys & Request.Form.Get
This sounds like a simple process right? Well it is a simple process, however, I ran into one problem. When you dynamically create text boxes they are rendered as input tags in the html and not as .net server controls with this tag
Now you may be thinking, what is she talking about? I can just loop through the Table’s row collection and get a reference to the textbox controls that way. Well I’m here to tell you that won’t work. Sorry L. You may be thinking that you can get to the textboxes via the form’s control collection. Well I’m here to tell you that won’t work either. So what’s a girl, or a guy, to do? Well ladies and gentleman, the answer is really simple.
All you have to do is use Request.Form.AllKeys and Request.Form.Get and you will be able to get a reference to those pesky controls all day long. Here is code you can use. In my case, I named those textboxes with a generic name and just incremented the numbers. So if a user requested 120 boxes, my textbox names would range from uTxt1 to uTxt120. That way I could loop through and use StartsWith(“uTxt”). Here is my code:
//variables
int i = 0;
string sValue = "";
foreach (string s in Request.Form.AllKeys)
{
//this lets me know that I have reached one of the controls that
//I dynamically created earlier
if (s.StartsWith("uTxt"))
{
sValue = Request.Form.Get(i);
this.ProcessRows(sValue);
}
i++;
}
That’s it! Now you can reference any of the controls at any time without any issues.
By the way, if you are using placeholder controls
Smooches,
Kila
Summary
Server controls are being rendered as html input controls in the final page and you need to access the values of these controls in the code-behind at runtime.
Error/Problem:
You can't get a reference by looping the control collections of the aspx page because all of the values return null and the controls values you need are being held by html controls and not server controls.
Solution:
Use Request.Form.AllKeys in combination with Request.Form.Get to get to the particular control and value you need. You can loop through the AllKeys collection using a foreach loop and then reference the item you need using Get.
Tuesday, November 20, 2007
Where Is IsNumeric In C#? Right Where It Should Be!
There were some happy smiles around the Internet when C# programmers thought that it was coming in the next version of dot NET. Oh well. You can wipe those happy smiles off of your faces. As you may or may not know, it just ain’t happenin’ folks! (Please don’t email me to correct my English. I say what I want. I’m a woman) So since it’s not already in C#, and it’s not coming to C#, what are we going to do? There are so many solutions floating around the Internet that I’m sure you can find one quickly, however, I say if you can’t beat’em join’em.
Here is where References come in handy. It’s not really earth shattering, but I’m sure that someone somewhere may find it useful. So put away your RegEx stuff and stop writing your own class and let dot NET do all of the work for you. I’m so lazy right?
At the top of your code-behind in your using section, add a reference to Microsoft.VisualBasic. It should look like this:
using Microsoft.VisualBasic;
Now in your code, you can reference IsNumeric like this:
bool bYourVariable = true;
//cast the variable to string to avoid an error if it really is a string
//the error you get if you don’t cast it first is that the string
//isn’t formatted properly
string whateverYouAreCheckingGoesHere.ToString();
bYourVariable = Information.IsNumeric(whateverYouAreCheckingGoesHere);
That’s it! Now you can laugh in the faces of our VB programming brothers and sisters all around the world and tell them that you have found the IsNumeric in C#. You have put the eggs back in the cake and you can bake! Tell them that C# rocks. Then go back to doing whatever it was that you were doing!
Smooches,
Kila
Summary
Using the IsNumeric function in C#
Error/Problem:
C# does not have a built in IsNumeric function
Solution:
Create a reference to Microsoft.VisualBasic and then use Information.IsNumeric(whateverYouAreCheckingGoesHere)
Saturday, November 17, 2007
Are your strongly typed datasets not generating Delete & Insert statements & stored procedures?
The reason is simple and the fix is simple too. The strongly typed dataset looks at your table to see if a primary key is defined. If your primary key is defined, then your delete and insert functions will be created. If you have been very bad and deserve a spanking and HAVE NOT defined a primary key, you will not see your Delete and Insert statements or stored procedures.
Now wasn't that simple?
Smooches,
Kila
Summary
Error: Delete & Insert stored procedures and statements are not generated in a strongly typed dataset
Cause: A Primary key is undefined on your table.
Fix: Define a primary key on your table and then define your dataset.
Comments anyone?
'the form' is undefined - Why can't things ever be simple?
Here is my latest little issue. I am working on a website that is going to be fantabulous (Please don't freakin' email me! I know it's not a REAL word! However, I'm a woman and I can say whatever I damn well please!). The site is called ShowOffYou and its a site for social site backgrounds, layouts and graphics. The exact address is http://www.showoffyou.com/. I'll keep you updated about it's "grand opening." Anyway let me get back to my story.
I am using master pages on this site. Code reuse - I just love it. Everything was going along smoothly and I was in a great mood. I created a .js file to hold all of my wonderful javascript functions and I added this file to my master page. I added it to my master page's head section using the following notation:
Everything was going along well until I tested my document. All of a sudden, I start getting these wonderful javascript errors. Now I could leave them, but I hate to give regular people out there a reason to think that I'm less than perfect :-). Here is the error.
Just in case you are lazy or just don't feel like clicking on the image above, I will tell you what it says. It says 'the form' sys is undefined. 'the form' is undefined??? Oh come on! :-(
Ok. I looked at the source code via the browser. It seemed fine. I looked at my web.config file. It looked just great. Ok. So what now??????
WELL, it appears that .Net does not like the way I did a particular thing. That THING is that I didn't use the end script tag. I CANNOT BELIEVE IT!!! This javascript error was caused because I didn't use an end script tag! What? Ok. What-Ev-Ver (Please don't email me to correct me. I know that whatever is not spelled What-Ev-Ver - but again, I can say What-Ev-Ver I want How-Ev-Ver I want.)
Here is the correct way the script should have been written.
That's it! If you get that dreaded 'theform' is undefined error, just make sure that your script tag has an end script. There may be additional reasons for this 'theform' is undefined error, however, this is a simple fix to look at first.
I hope someone benefits from my 'theform' is undefined ramblings.Have lots of dotnet fun people!!
Smooches,
Kila
Summary
Error: Javascript error displayed to end users in their browser - 'theform' is undefined
Cause: Defining the script tag without an ending script tag in the head section of your asp.net document.
Fix: Change the way you define the script tag. Make sure that there is a beginning tag and a full end tag. See the images above.
Comments anyone?