|
This is not an answer of my question.
|
|
|
|
|
If someone is paying you for this, they are more lost even than you are. If you're programming for fun, then choose a more sensible project.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
This is not an answer to my question.
|
|
|
|
|
Hi All,
i have 4 textboxes.
when the length of text in first textbox is equal to 4 then it should "automatically" change its focus to next textbox. i have set the autopostback to true but i need to click on screen to make a postback.
i used onKeyPress, onKeyUp, onTextChanged but nothing is working for me... or is there any mistake in my code..
.aspx page :
<asp:textbox id="TextBox1" runat="server" onkeyup="textLength()" xmlns:asp="#unknown">
javascript code :
function textLength() {
var val = document.getElementById("TextBox2").value;
if (val.length == 4) {
document.getElementById("TextBox3").Focus();
}
}
in .aspx.cs page:
TextBox2.Attributes.Add("onKeyUp", "javascript: textLength();");
is there any way to achieve this..
Thanks in Advance.
|
|
|
|
|
What do you mean by 'not working' ? I'd write a method that takes the id of the textbox you want to move to, the textbox you're in, and the length you're looking for, so you can reuse it. onkeyup="myfunc(this)" would pass the control instance, then you only need to look up the other one.
Make sure that the client side id is 'TextBox2', it probably isn't. You use the ClientID property of the server control to get the client side Id.
Never use a control you got with getElementById without checking first if it's null.
You can also install firebug for firefox and step through your script to make sure it's called, and see how it's working. Or use alerts to tell you when they get called, if you want something less functional but easier to set up.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
Hi,
thanks for replying...
my javascript is not executing .
i verified my code many times. iam unable to figure it out (why javascript is not executing).
this is my entire code:
protected void page_load(object sender, EventArgs e)
{
if(Page.IsPostBack)
{
TextBox2.Attributes.Add("onKeyUp", "javascript: textLength();");
}
}
]]>
<title>Untitled Page
function textLength() {
alert("its called");
var val = document.getElementById("TextBox1").value;
if (val.length == 4) {
document.getElementById("TextBox2").Focus();
}
}
<asp:textbox id="TextBox1" runat="server" autopostback="true" xmlns:asp="#unknown">
onKeyUp="textLength(this)" >
<asp:textbox id="TextBox2" name="t2" runat="server" ontextchanged="TextBox_TextChanged" xmlns:asp="#unknown">
Is everything is correct ?
|
|
|
|
|
I think onkeyup should be all lowercase.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
still its not working...
any other suggestions....
thanks
|
|
|
|
|
why should'nt you tried it in c# ontextchanged event and still if you want your javascrit running are you sure you checked advance browser settings to enable javascript
(are you disabled them???? )
or maybe this onkeyup="texlenght()" need a ";" or onkeyup="textlenght();"
hope this should help.
|
|
|
|
|
Make sure onkeyup is a javascript event, and look at the HTML that's being generated to see if it looks the way you'd expect.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
I am inserting a new row in a database table (MSSQL).
I want to retrieve the value of Identity column associated with 'this' new row.
My stored procedure is as follows :
ALTER PROCEDURE dbo.Insert
(
@SubCategoryId tinyint,
@text nvarchar(MAX),
@Url nvarchar(2000)
)
AS
SET NOCOUNT ON;
INSERT INTO Table1
(SubCategoryId, text, Url)
VALUES (@SubCategoryId,@text,@Url)
SELECT NEWID = SCOPE_IDENTITY()
Now, I have a table-adapter in which i have any Insert function which uses the above stored procedure.
From the code-behind, i am inserting the data.
DataSetTableAdapters.Table1TableAdapter t1 = new DataSetTableAdapters.Table1TableAdapter();
int result = t1.Insert((byte)int.Parse(ddlSubCategory.SelectedValue), txtText.Text, txtUrl.Text);
The row is inserted in the database, but the returned value is not the Identity column ...
Is the stored procedure incorrect ?
I posted this in ASP.NET forum, because i want to do this in ASP.NET, i found the stored procedure on a database related site, still the stored-procedure is not working ...
Apurv
“Never trust a computer you can’t throw out a window.”
(Steve Wozniak)
“There are only two industries that refer to their customers as ‘users’.”
(Edward Tufte)
|
|
|
|
|
It's still a SQL question.
Does 'I found the stored proc' mean you don't really understand what it does ? I suspect your core issue is probably that the table adapter 's insert method probably doesn't return the result of the proc, but a value such as the number of rows changed. Hard to say, you don't say what value you're getting back, but SCOPE_IDENTITY() will return that new id, so I don't see what the issue could be. The reason to use this is, it will return the id that your proc created, if you added SQL to find the highest id, and it was called by two users at once, you'd have a race condition.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
Christian Graus wrote: Does 'I found the stored proc' mean you don't really understand what it does ?
not 100% true.
Actually I am not good at writing the stored procedures.
Christian Graus wrote: the table adapter 's insert method probably doesn't return the result of the proc
this could be the issue ...
But my task is straight forward, I have to first Insert a row in one table, then using the value of the Identity column of the created row, some rows are to have inserted into other table where, the primary-key in this table is Foreign key in the other table.
What should be the approach to this problem ?
Apurv
“Never trust a computer you can’t throw out a window.”
(Steve Wozniak)
“There are only two industries that refer to their customers as ‘users’.”
(Edward Tufte)
|
|
|
|
|
how to call function in class page to default.asp x
|
|
|
|
|
Umm, MethodName(//PossibleParameters)
I would highly suggest getting a book on ASP.NET, C#/VB.NET if you don't know how to even call a method.
The best way to accelerate a Macintosh is at 9.8m/sec² - Marcus Dolengo
|
|
|
|
|
This guy is either a troll, or an absolute moron. I'd recommend ignoring his posts.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
OK, at this point I am certain that this is some sort of joke. Your questiosn get stupider and stupider, it's obvious that you can't be serious. The joke isn't funny, please stop it.
Christian Graus
Driven to the arms of OSX by Vista.
|
|
|
|
|
Hi all,
First of all i wud like to express my heartiest gratitude to the expertsof codeproject who have been helping me time to time so that i dont remain stuck with a particular problem.
My Prob:
I was using VS2005 for building my application but suddenly due to some unavoidable circumstances we are forced to migrate to VS2003.But I am not too well-versed with VS2003 andm finding it a bit difficult to convert my app into VS2003.
One such problem is that I was using string.contains in VS2005 but now I see that it doesnt exist in VS2003.So I wud like to know is there a way to implement the same feature in VS2003??plz help me out!!!!
|
|
|
|
|
First of all, this has nothing to do with visual studio. VS is just an editor. Documentation[^] for string.Contains says it is supported only on .NET framework 3.0 or later. In .NET 1.1, you have to use String.IndexOf[^] method to see whether a character exist or not.
|
|
|
|
|
I have a table in a database with certain fields which the user fills up through a form.At a later point,if the user wishes to see this form,I need to auto-fill those fields.The auto-fill works except for the DropDownList control.It always sets its field to the first item in the datalist.I tried 'DropDownList2.Items.FindByText(string).selected="True"' but it shows an error. I need the dropdownlist to show the text that was previously selected by the user and also giving the user an option to change his previous selection.
How do i do this?
|
|
|
|
|
DropDownList.Items.IndexOf(DropDownList.Items.FindByValue("InsertValueToFind"))
That is one of the ways I do it.
The best way to accelerate a Macintosh is at 9.8m/sec² - Marcus Dolengo
|
|
|
|
|
|
Do you set the value of the DropDownList, or just the text?
The best way to accelerate a Macintosh is at 9.8m/sec² - Marcus Dolengo
|
|
|
|
|
Try the FindByText one.
The best way to accelerate a Macintosh is at 9.8m/sec² - Marcus Dolengo
|
|
|
|
|
HI. got a project where you have a file menu, and you open a text file, then save the text file. and a exit menu item. now, if i click the open file menu item, it displays two text boxes, where you enter a name and phone number. but for some stupid reason, if i click the save menu item, i get a message saying the file needs to be open, and does not save the file? so what am i doing wrong and how to fix this? any help would be gretefully aprreciated. will post the code below. cheers Marvin.
'Program: Ch11 Open and Write File
'Programmer: Marvin Hunkin
'Date:Saturday March 7 2009
'Description: Allow the user to enter names and phone numbers and
' save them in a file.
Imports System.IO
Public Class frmCh11OpenAndWriteFile
' Declare module-level variable.
Dim PhoneStreamWriter As StreamWriter
Private Sub menSaveToolStripMenuItem_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles menSaveToolStripMenuItem.Click
' Save the record to the file.
If PhoneStreamWriter IsNot Nothing Then ' Is the file open?
With Me
PhoneStreamWriter.WriteLine(.tbNameTextBox.Text)
PhoneStreamWriter.WriteLine(.tbPhoneTextBox.Text)
With .tbNameTextBox
.Clear()
.Focus()
End With
With .tbPhoneTextBox
End With
End With
Else ' File is not open
MessageBox.Show("You must open the file before you can save a record", _
"File Not Open", MessageBoxButtons.OK, MessageBoxIcon.Information)
End If
End Sub
Private Sub menOpenToolStripMenuItem_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles menOpenToolStripMenuItem.Click
' Open the file.
Dim dlgResponseDialogResult As DialogResult
' Is the file already open?
If PhoneStreamWriter IsNot Nothing Then
PhoneStreamWriter.Close()
End If
' Begin in the project folder.
dlgOpenFileDialog.InitialDirectory = "C:\" ' Display the File Open dialog box.
' Make sure that the user didn’t click the Cancel button.
If dlgResponseDialogResult <> DialogResult.Cancel Then
' Open the output file.
End If
End Sub
Private Sub menExitToolStripMenuItem_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles menExitToolStripMenuItem.Click
' Close the file and the form.
If PhoneStreamWriter IsNot Nothing Then ' Is the file open?
PhoneStreamWriter.Close()
End If
Me.Close()
End Sub
End Class
|
|
|
|