Am new to Access.
Have a field on a form called Surname.
I would like to add an expression to the AfterChange event for this field that would change its field to say uppercase.
What should the expression say? (once I get the syntax correct I will then be able to work out how to build it).
thanks
You would be able to do this in VBA quiet easily I would guess. Not sure if Expression builder would be able to do that for you. With VBA you will use,
Private Sub yourControlName_AfterUpdate()
Me.yourControlName = UCase(Me.yourControlName)
End Sub
If you are new to VBA, then check out how to write your very first VBA code : www.baldyweb.com/FirstVBA.htm
Hope this helps !
Related
I have implemented a routing functionality successfully in my project (a news website):
Sub RegisterRoutes(ByVal routes As RouteCollection)
routes.MapPageRoute("ndetails", "news/{title}/{id}/", "~/newsdetail.aspx")
End Sub
and I set the URLs like this (databound to a repeater):
href="<%# Page.GetRouteUrl("ndetails", new with { .title= Server.UrlEncode(Eval("Title")), .id= Eval("NewsID")})%>"
The URL produced is like:
/this%20is%20a%20news%20item/89
As can be seen above, the URL part is difficult to read and I would like it to be like:
/this_is_a_news_item/89
I thought of going for a Replace function. But then, since the user creating the news might enter any string, I have to take into account all the other characters that might need to be replaced.
I just wanted to know from an experienced developer, whether going with a long replace function is the way to go, or is there another solution to format my URLs in this rouitng scenario.
Many thanks in advance
AFAIK there is no built in funcitonality in the framework to make url "pretty". You have to implement your own url fo rewriting the title.
In the save of your entities simply use a function that do the replaces that you need (' ' with '_' or example) and then use UrlEncode.
You can also use a Regular expression to do the replacement in one go.
I want get the most specific from the current url in visual basic .net.
I've tried several code but it just was the same.
I have this code:
Dim CurrentURL1 As String = Request.Url.PathAndQuery
The code will result like: /FolderName/CurrentUrl.aspx
What I want is, just get the 'CurrentUrl.aspx'.
How to get that?
Have you tried Path.GetFilename ?
http://msdn.microsoft.com/en-us/library/system.io.path.getfilename.aspx
Actually, I think you can use the Uri class, the class is better suited for your needs. It has several properties you can use to get what you want.
http://msdn.microsoft.com/en-us/library/system.uri.aspx
Apologies if this seems like a duplicate post...
Thomas Warner kindly answeres an earlier post suggesting I use:
Popup.aspx?Data1=Piece_of_data&Data2=Piece_of_data
Just want to ask, if my code is Popup.aspx?Data1=textbox1.text&Data2=textbox2.text
whats the proper way to reference whats in the textboxes?
The way is is above, all that appears in the popup is the actual text 'textbox1.text'
rather than what is actualy in that control.
thanks again
Using asp.net you can litterally write the value straight into the string like:
Popup.aspx?Data1=<%=textbox1.Text%>&Data2=<%=textbox1.Text%>
A more ideal way of doing this would be to build up the URL string in your codebehind so as not to clutter up your HTML and C# code.
That way you could do something like:
String popupUrl = String.Format("Popup.aspx?Data1={0}&Data2={1}",
textbox1.Text,textbox2.Text);
This will also allow you to do any sanitization checks on the values from the textboxes before you start passing those values around.
I currently have this line of code which has been working for the past 6 months:
If IsNumeric(txtProductID.Text) Then
...do stuff
Else
Dim msg As String = "Error!"
End If
All of the sudden, no matter what kind of entry is put in txtProductID (including plain numbers), it fails! Is there reason for me to be going crazy over this?
Kind of a shot in the dark, but one thing to watch for is that maybe someone wrote a private method called IsNumeric within the same class. Are you sure that the code above is executing Microsoft.VisualBasic.IsNumeric()? If you put your cursor on IsNumeric and hit F12 where does the definition point to?
Try Trim()ing the string before passing it into the function. In addition, rather than using a VB-specific function like IsNumeric, you might try an approach like this:
Dim input as Integer
If Integer.TryParse(txtProductID.Text, input) Then
....do stuff with input
Else
Dim msg as String = "Error!"
End if
If your number is a decimal number, there are corresponding functions on Double and Single as well.
As to the particular reason that IsNumeric is failing, I couldn't tell you. I can tell you, though, that I've always found it helpful to stick to BCL-compliant functions that are language-agnostic rather than language-specific, like IsNumeric, Str, etc.
ugh... i'm an idiot... thanks for your help guys, but apparently i was clearing my whole form before accepting input, so "" will never pass as "IsNumeric". Please don't look at this question again. I feel ill.
Thanks again for your help.
A requirement for an ASP.Net 2.0 project I'm working on limits a certain field to a max of 10 words (not characters). I'm currently using a CustomValidator control with the following ServerValidate method:
Protected Sub TenWordsTextBoxValidator_ServerValidate(ByVal source As Object, ByVal args As System.Web.UI.WebControls.ServerValidateEventArgs) Handles TenWordsTextBoxValidator.ServerValidate
'' 10 words
args.IsValid = args.Value.Split(" ").Length <= 10
End Sub
Does anyone have a more thorough/accurate method of getting a word count?
You can use one of the builtin validators with a regex that counts the words.
I'm a little rusty with regex so go easy on me:
(\b.*\b){0,10}
This regex seems to be working great:
"^(\b\S+\b\s*){0,10}$"
Update: the above had a few flaws so I ended up using this RegEx:
[\s\x21-\x2F\x3A-\x40\x5B-\x60\x7B-\xBF]+
I split() the string on that regex and use the length of the resulting array to get the correct word count.
I voted for mharen's answer, and commented on it as well, but since the comments are hidden by default let me explain it again:
The reason you would want to use the regex validator rather than the custom validator is that the regex validator will also automatically validate the regex client-side using javascript, if it's available. If they pass validation it's no big deal, but every time someone fails the client-side validation you save your server from doing a postback.