|
Hi. I'm a relatively new programmer to VB .NET so have a few stupid questions.
On validating user inputs into textboxes and such, is there a way to validate or restrict input to number or alphanumeric only? The few instructions I found seems to require creation of custom codes to do so. I'm getting frustrated by this atm. One workaround that I did was:
dim currentstring as string
KeyDown event
if the key pressed was a number (or backspace), then don't do anything
else set a flag to true
end if
TextChanged event
if flag is true then restore original currentstring
else currentstring = txt.Text
end if
flag = false
So in essence, if a user presses any other key aside from backspace and numbers, it restores the string in the textbox to the last successful string input (currentstring).
Then another question is whether I can retrieve the source of a webpage without the use of ASP. The idea of the program is to be able to get a word count of a webpage just by entering the URL.
Thanks for any help with these dilemmas.
|
|
|
|
|
There lots of way of doing it.
The more appropriate (in terms of OOP) is to write a class (i.e. NumericTextBox) that inherits from TextBox and adds the functionality you require.
But if you look around there are tons of pre built classes for that.
About retrieving web pages you don't need any ASP. Just have a look at the .NET FW documentation and you'll see that there are classes ready to be used for that. Thay may differ from 1.x to 2.x. Try to use one of the WebRequest derivated classes.
|
|
|
|
|
I don't understand this one...
Almost everything works except the Update on the grid: Delete, Cancel, Edit*
If I take the Load_Grid out of m_dgIDs.EditCommand--I have to click the Edit link twice for it to turn into a textbox that I can edit, but the original content is not there.
If I leave the Load_Grid in the EditCommand, the textbox will appear immediately with the cell's content and I can edit it. HOWEVER, the grid no longer appears to be bound and this line blows up:
Dim id As Integer = CType(e.Item.Cells(0).Text, Integer)
e.Item.Cells(0).Text is = "" or nothing
I tried to keep this code to a MIMIMUM because I know it is a lot to ask of forum members, but if someone has the time, I would appreciate any thoughts on the subject.
Thanks - A Lot.
Private Sub Page_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
If Not IsPostBack Then
Load_DropDown()
End If
End Sub
Private Sub m_ddFacility_SelectedIndexChanged(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles m_ddFacility.SelectedIndexChanged
Load_Grid()
End Sub
Private Sub dgIDs_Update(ByVal sender As Object, ByVal e As DataGridCommandEventArgs) Handles m_dgIDs.UpdateCommand
'ID is just a simple class that interfaces with the database & has 3 properties
'CostCenterID, FacilityID, & Description...pretty trivial
Dim oCostCenter As New ID
Dim id As Integer = CType(e.Item.Cells(0).Text, Integer)
oCostCenter.Load(id)
oCostCenter.Description = CType(e.Item.Cells(2).Text, String)
oCostCenter.FacilityID = m_ddFacility.SelectedValue
oCostCenter.Update()
Load_Grid()
m_dgIDs.EditItemIndex = -1
End Sub
Private Sub dgIDs_Edit(ByVal sender As Object, ByVal e As DataGridCommandEventArgs) Handles m_dgIDs.EditCommand
m_dgIDs.EditItemIndex = e.Item.ItemIndex
Load_Grid()
End Sub
Private Sub dgIDs_Delete(ByVal sender As Object, ByVal e As DataGridCommandEventArgs) Handles m_dgIDs.DeleteCommand
Dim oCostCenter As New ID
Dim id As Integer = CType(e.Item.Cells(0).Text, Integer)
oCostCenter.Load(id)
oCostCenter.Delete()
Load_Grid()
End Sub
Private Sub dgIDs_Cancel(ByVal sender As Object, ByVal e As DataGridCommandEventArgs) Handles m_dgIDs.CancelCommand
m_dgIDs.EditItemIndex = -1
Load_Grid()
End Sub
Private Sub Load_Grid()
Dim ds As DataSet
Dim oData_Dev As New CFormData("DefaultConnectionString")
ds = oData_Dev.GetDataSet("SELECT * FROM CostCenter WHERE FacilityID = " & m_ddFacility.SelectedValue.ToString())
m_dgIDs.DataSource = ds
m_dgIDs.DataBind()
End Sub
Private Sub Load_DropDown()
Dim ds As New DataSet
Dim oData_Dev As New CFormData("DefaultConnectionString")
ds = oData_Dev.GetDataSet("SELECT * FROM Facility")
m_ddFacility.DataSource = ds
m_ddFacility.DataTextField = "FacilityName"
m_ddFacility.DataValueField = "FacilityID"
m_ddFacility.DataBind()
End Sub
---The Page---
<%@ Page Language="vb" AutoEventWireup="false" Codebehind="GridPage.aspx.vb" Inherits="TestEnv.GridPage" %>
<HTML>
<HEAD>
<title>GridPage</title>
<meta content...>
</HEAD>
<body MS_POSITIONING="FlowLayout">
<form id="Form1" method="post" runat="server">
<TABLE id="Table1" cellSpacing="1" cellPadding="1" width="300" border="1">
<TR>
<TD colSpan="2">
<asp:datagrid id="m_dgIDs" runat="server" Width="100%" AutoGenerateColumns="False">
<Columns>
<asp:BoundColumn Visible="False" DataField="CostCenterID" HeaderText="CostCenterID"></asp:BoundColumn>
<asp:BoundColumn Visible="False" DataField="FacilityID" HeaderText="FacilityID"></asp:BoundColumn>
<asp:BoundColumn DataField="Description" HeaderText="Description"></asp:BoundColumn>
<asp:EditCommandColumn ButtonType="LinkButton" UpdateText="Update" CancelText="Cancel" EditText="Edit"></asp:EditCommandColumn>
<asp:ButtonColumn Text="Delete" CommandName="Delete"></asp:ButtonColumn>
</Columns>
</asp:datagrid></TD>
</TR>
<TR>
<TD>
<asp:DropDownList id="m_ddFacility" runat="server" AutoPostBack="True"></asp:DropDownList></TD>
</TR>
</TABLE>
</form>
</body>
</HTML>
|
|
|
|
|
Yeah, I am not sure what the "real" answer was to this. I threw it all away, used the MS example from help--then, added my code back in. I could post it upon request.
Thanks Anyway.
William
|
|
|
|
|
I have a situation where I have standard form class that I created. It inherits from System.Windows.Forms.Form as a public class. The only thing added to this class is a series of variables for passing data to these forms. There are no functions or overrides in the class.
I then create a FRIEND form that inherits this class. I put a textbox on the form and I can't use CTRL-V. In fact, I trapped the keydown events and if I do 'V', I get a keycode, if I do CTRL-SHIFT-V, I get a keycode, but if I just do CTRL-V, I don't even get a keycode (it never throws the keydown event at all.) And it won't paste anything into the control.
If I change the form to inherit the System.Windows.Forms.Form directly, it traps fine and pastes the text from the clipboard into the control.
Any ideas as to what would cause this to happen?
--In a world without fences, who needs Gates?
|
|
|
|
|
I am trying to figure out how to send data and my customer to my banks web site to enroll for paying their bills online.
The post string that I am suppose to use is:
https://banks_web_site.com/enroll?id=12345&name=Customer&accountid=98765&backurl=https://my_web_site.com/return.aspx
The bank will return to me the following info and my customer (so they can continue the payment process) via https://my_web_site.com/return.aspx?return=0&enroll_id=765431
I'm having trouble trying to get this to work, any help would be appreciated.
Another thing that has me stumped is if I do what the bank calls a payment search, I send to them with no return url:
https://banks_web_site.com/pay_search?id=12345&&enroll_id=765432&days=2
They will return the following:
0:::
7777:1:1123123123:VISA:987554
8888:1:1231238744:AMEX:876454
Unlike the first example, the returned info is not qualified by a query string name. How do you receive this data ?
|
|
|
|
|
Response.Redirect("https://banks_web_site.com/enroll?id=12345&name=Customer&accountid=98765&backurl=https://my_web_site.com/return.aspx")
|
|
|
|
|
Hi Again,
Request.QueryString should help with your other problem.
Can you keep the questions to the forum, rather than Emailing me directly please?
PS: All of this can be found in MSDN if you have a hunt around. You may find it quicker that posting because you will be able to find it as required.
Thanks,
L
MCSD(VB6/SQL7)
MCAD(C#/SQL2000)
MCSD(C#/SQL2000)
|
|
|
|
|
Thanks
Sorry for the email
|
|
|
|
|
I did look in MSDN and it showed using the request.query.string without any parameters and the output as being unparsed. But what they don't show and I don't understand is how I get the unparsed data into a variable that I can parse. The data that I will be receiving does not have any parameter names just data.
Thanks
|
|
|
|
|
Ok, try the following code, then call the page with a string appended to the url after a question mark. For example "http://LocalHost/TestWebSite/WebForm1.aspx?ARandomStringThatIAddedToTheURL"
Dim sQueryString As String = ""
For index As Integer = 0 To (Request.QueryString.Count - 1)
sQueryString &= Request.QueryString(index) & "<BR>"
Next
Response.Write("Query String: <BR><BR>" & sQueryString)
MCSD(VB6/SQL7)
MCAD(C#/SQL2000)
MCSD(C#/SQL2000)
-- modified at 3:57 Thursday 3rd November, 2005
|
|
|
|
|
Hello to all,
I use this method to run rwrun60
Public Sub ExecuteReport(ByVal ProcessPath As String)
Dim objProcess As System.Diagnostics.Process
Try
objProcess = New System.Diagnostics.Process
objProcess.StartInfo.FileName = ProcessPath
objProcess.StartInfo.WindowStyle = ProcessWindowStyle.Normal
objProcess.Start()
'Wait until the process passes back an exit code
objProcess.WaitForExit()
'Free resources associated with this process
objProcess.Close()
Catch
MessageBox.Show("Could not start process " & ProcessPath, "Error")
End Try
End Sub
if i try the ProcessPath string like for example "notepad.exe"
everything works, but if i use rwrun60....
ProcessPath = "rwrun60 report=c:\PathToReports userid=AccessInfo paramform=no destype=FILE DESNAME=c:\Temp\ReportName.PDF DESFORMAT=PDF P_FORMATO=PDF batch=YES"
gives an exception... file not found !?
if i run on Dos shell works fine.
How can i know what is the problem?
Thanks for your time
The string
-- modified at 6:58 Wednesday 2nd November, 2005
|
|
|
|
|
This is because your command line arguments must be seperated from your executable. You might also have to specify the full path to the .EXE
ProcessPath = "C:\whatever\path\to\exe\rwrun60"
ProcessArgs = "report=c:\PathToReports userid=AccessInfo paramform=no destype=FILE DESNAME=c:\Temp\ReportName.PDF DESFORMAT=PDF P_FORMATO=PDF batch=YES"
.
.
.
objProcess = New Process
With objProcess.StartInfo
.FileName = ProcessPath
.Arguments = ProcessArgs
.WindowStyle = ProcessWindowStyle.Normal
End With
objProcess.Start()
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
-- modified at 12:46 Wednesday 2nd November, 2005
|
|
|
|
|
Thanks.
Works just fine , dumb question
|
|
|
|
|
Hello, i have a similar problem...
I can run a report from command line whith this...
rwrun60 module=D:\Sodexo\Reports\SODMAR0007.rep paramform=NO execmode=batch PRINTJOB=NO userid=andes_supervisa/andes@SODEXODB mode=bitmap destype=file desformat=pdf desname=D:\Sodexo\Reports\salida4.pdf NUM_PRE_INI=307484 NUM_PRE_FIN=307484 PREFIJO=FC
and in this way, its ok, and generate the salida.pdf
The problem occurs when i want to call the report from a VB programm, and the process rwrun60 executes but it not return. i can see it on task manager.
I prove calling from prcedure from oracle, and the same happend.
so, i dont know wath happend whit it.
Any idea?
Thanks
|
|
|
|
|
I am doing a programme in VB using MS Access as database. I used ActiveX 2.8 for connection by ADODB. But I cannot open the database which is password secured though I know the password.
THe Error mesage recieving is "Work Group Information missing, It is already opened by another user." Kindly pls help me to solve the problem
|
|
|
|
|
|
Hi, does anyone know how to build a patch (the correction) for an application that we already deploy?
Example: my project has one form which contain one button. When the user press the button it display the message box "Hello world". And now I need to change the meaning of the message box from "Hello world" to "Hello everybody". I don't want to change the code and recompile my application again to redeploy it. But what i want is just make a small execute file that after a quick set up it will change the meaning of the message as i mention above. The purpose is like the small patch file that Microsoft used to allow the user to download in order to improve the security of each computer.
|
|
|
|
|
If the strings are emedded into the EXE file then a redeploy will be required. If you have put them into an external resource file of some kind you could just re-deploy that, but I am guessing that this is not the case here.
|
|
|
|
|
Thank you very much for your comment. But what i want is not redeploy an application. I just build a new small exe and set up then change the behavior of my application. Like Microsoft build a service pack or a small patch.
|
|
|
|
|
Microsoft patch Windows by replacing the neccesary components.
Remembver that Windows is made up of hundreds or thousands of individual files. When they release a patch it simply replaces the files that need to be changed. If your application simply consists of one file you will need to replace it, if it consists of multiple files, and you only need to change some of them then simply re-deploy the ones you need to change.
MCSD(VB6/SQL7)
MCAD(C#/SQL2000)
MCSD(C#/SQL2000)
|
|
|
|
|
I would suggest doing an md5 on all the files included, and just replace the ones that are different.
I bet theres a solution out there that does this?
All your source are belong to us!
|
|
|
|
|
AndrewVos wrote: I would suggest doing an md5 on all the files included, and just replace the ones that are different.
Thank you very much for your solution, but I don't know what is MD5. Could you give me more detail about this?
|
|
|
|
|
Roath,
I don't know if you've already found a solution? If not PatchWise Free is probably what you're looking for. As its name suggests, it's Freeware and really does a great job.
HTH
Jottum
|
|
|
|
|
Thank you very much for your solution. Until know i did not know any better solution. Hope that this software could do as what I expected.
|
|
|
|