PWNettle
Avatar/Signature-
Posts
129 -
Joined
-
Last visited
About PWNettle
- Birthday 03/03/1968
Personal Information
-
Occupation
Programmer/Web Developer
-
Visual Studio .NET Version
VS.Net 2003 Architect (C#/ASP.Net)
-
.NET Preferred Language
C#
PWNettle's Achievements
Newbie (1/14)
0
Reputation
-
You can't really control where Response.Write ends up, but you can give an element in your ASPX page an ID and a runat="server" so that you can manipulate it in code (ideally code behind). So as kahlua001 suggests, in your ASPX you might have (an asp.net label control inside an html paragraph element): <p><asp:label id="lblWhatever" runat="server"></p> An asp:label control is just an html span that's encapsulated as an object for ease of coding. It allows you to richly manipulate it via .Net code, but ultimately ASP.NET rendars an asp:label as an html span tag with appropriate attributes and styles based on how you've manipulated it in code. In your code it'd be declared in the appropriate section as: [csharp]protected System.Web.UI.WebControls.Label lblWhatever;[/csharp] Which would then enable you to bold using Kahlua001's suggestion or to do it more manually with: [csharp]lblWhatever.Text = "<b>ASP.NET is fun!</b>";[/csharp] Paul
-
Try: web1.Document.getElementById("fieldname").value = "testdata" Paul
-
I'm not really sure what it is that you're doing, but... Assuming that your dropdownlist's values are actually text (and not some numeric equivalent, you could add something like this (probably as a function since the dropdown value can change and you'll need to call the code when it changes). function changeMaxChars() var oDropDown = document.getElementById("ddMessage"); if (oDropDown.value == "Email") { MaximumCharacters = 500; } else if (oDropDown.value == "SMS" || oDropDown.value == "EMail & SMS") { MaximumCharacters = 160; } } On your dropdown list you'll need to add a javascript event handler (I think, if not then disregard) to fire the routine above, something like: <asp:dropdownlist id="ddMessage" runat="server" onchange="changeMaxChars();" /> onchange isn't an asp.net webcontrol event so there's no risk of conflicting with asp.net when you add that into the asp.net webcontrol declaration. Good luck, Paul PS - That javascript you posted makes me cringe, especially the misuse and abuse of eval(). I'd recommend writing your own script if at all possible!
-
Regular Expression Validator - Illegal characters
PWNettle replied to kristoffera's topic in Regular Expressions
Validator controls seem to not fire at all if the target control is empty. So, sadly, if you want to validate by regular expression and want the field to be required (no empty strings) then you may need to use two validators - a regular expression validator and a required field validator. I think custom validators always fire - so you can duplicate the functionality of both in one custom validator - but to me this seems like a poor solution (as in, it seems like one shouldn't have to do this). If someone knows a way around this I'd be glad to hear/read it because using two validators in this type of situation irks me! Paul -
Regular Expression Validator - Illegal characters
PWNettle replied to kristoffera's topic in Regular Expressions
Sure - you just have to construct your regular expression properly. You might refer to "regular expressions, syntax" in MSDN for a list of all the characters and symbols one can use in a regular expressions. For ex: [^a-c] matches any character that's not a through c, but chances are you'll need more than just that to accomplish whatever you're after. Paul -
Assuming you have properly declared the checkbox in your code, and assuming that you're properly setup the control in your .aspx (by setting runat=server and giving the control an 'id' tag) then regardless of whether you're using an ASP.Net Checkbox webcontrol or an HtmlInputCheckbox you would set its 'Checked' property. chkControlName.Checked = True chkControlName.Checked = False Paul
-
If by 'Header Height' you're referring to the title bar, then you can use: SystemInformation.CaptionHeight Paul
-
Are you setting the 'From' property on your messages? I would guess that your mail client marks emails as bulk based on subject text or sender moreso than the server that it comes from (unless it's been configured to know that particular IPs are spammers, which is unlikely for your localhost). Paul
-
There are several ways you can accomplish this. One commonly used way is to use the Session object, which you might use (after a successful login) like: [csharp]// where sUsername is a string holding the username // where nUserId is an int holding the user's ID number Session.Add("username", sUsername); Session.Add("userid", nUserId);[/csharp] It's up to you what you store off for user info. Session can hold objects too so if you have a user object you could store the entire user object off if you wanted to. You can get values out of session just as easily: [csharp]string sUsername = Session["username"]; int nUserId = Session.Contents["userid"]; // variation[/csharp] Sessions can expire so you'll usually want to check for nulls or wrap a try/catch around the code that grabs the values. In a robust app you might have the user re-login if their session expire. Another similar way to track user info is with cookies. Cookies are a little more flexible. Cookies are always stored on the client machine (Sessions can be setup for different storage mechanics, but it's often server-side storage). A simple cookie example: [csharp]HttpCookie oCookie = new HttpCookie("logininfo"); oCookie["username"] = sUsername; oCookie["userid"] = nUserId; oCookie.Expires = DateTime.Now.AddHours(2); Response.Cookies.Add(oCookie);[/csharp] And to retreive values: [csharp]HttpCookie oCookie = Request.Cookies["logininfo"]; string sUsername = oCookie["username"]; int nUserId = int.Parse(oCookie["userid"]);[/csharp] And again - you usually want to check for null or use a try/catch because cookies can expire too. The syntax would be similar if you're using VB.Net. For more info on either, refer to MSDN, google, or search around here. Paul
-
One way is to use the System.Diagnostics.Process object, for ex: [csharp]// C# Example System.Diagnostics.Process oProcess = new System.Diagnostics.Process oProcess.Start("http://www.somedomain.com");[/csharp] ' VB.Net Example Dim oProcess As New System.Diagnostics.Process oProcess.Start("http://www.somedomain.com") It'll launch the URL into the default browser. Paul
-
Your thinking should work as long as you use the same type of object throughout (I'm not sure about the casting potential between Image and Bitmap objects - for ex, putting an Image object in the hashtable and then trying to cast it to a Bitmap object might not work). I also don't see why you'd put brackets around the key (myHashtable.add(["pic1"],...) since that doesn't even compile (maybe that's just the way you typed it here...). Hashtables store everything as type Object so you'll usually need to explicitly cast the contents when you want to use them. So, either do both as Bitmaps: myHashtable.Add("pic1", new Bitmap("path")); Bitmap picture = (Bitmap) myHashtable["pic1"]; Or as Image objects: myHashtable.Add("pic1", Image.FromFile("path")); Image myImage = (Image) myHashtable["pic1"]; PictureBox1.Image = myImage; (I tried the Image object variant above on a .jpg image and it worked fine...)
-
I'm not a regex fanatic but I think the use is appropriate here. Why use 10 lines of code to handle a specific situation when 3 lines of code that are much more flexible do the job? In this case the regex use is extremely simple, it's not like a highly complex pattern is in use or isolating substrings is occurring. In your sample you create a structure and a special function that converts text to char, loops, and processes - and you're saying using regex is overkill? Ok... On any machine that can run .Net reasonably well I seriously doubt the performance hit of using regex is going to be an issue.
-
One way to do this would be to use a regular expression - or more specifically use the Replace method of a regular expression object. Here's a C# example...the VB.Net syntax would be very similar: Regex oRegex = new Regex(@"\D"); string sTest = "abcXYZ123abc"; sTest = oRegex.Replace(sTest, ""); MessageBox.Show(sTest); // displays "123" The pattern for the regex is setup as "\D" (in C# that @ before the string literal tells C# to take the string contents literally, since backslash in an escape character otherwise - I don't think you'd need that @ in VB.Net), which indicates to match any non-digit character. That pattern is applied to the target string when the Replace method is invoked, and in this case each non-digit occurance is being replaced with an empty string, so you end up with a string stripped of all non-digit characters. For more help with regular expressions you might visit that particular forum here or check out 'regular expressions, syntax' (and other topics) in MSDN. Good luck, Paul
-
I'm from a land where "r" and "u" are letters, not words. :-/ I think it's more commonly known as the land of old age. :p
-
Another option might be to create a virtual mapping to only your "includes" folder off the root - that way any project you create could link to it with "/includes/..." regardless of where it was in the virtual heirarchy. A server can host multiple sites, for sure, but that doesn't mean that you as a developer will run a development environment that works the same way (and hopefully you develop seperate from your live sites!) It might depend on what operating system you have, what web server you have, and what your network will let you get away with.