hello, i have two textbox column and one button control in gridvie when i click button it will ask plese enter price in first textbox . when enter values it is asking again. how to pass textboxid in javascript
.my code is 2 12887 acoder 16,027
Recognized Expert Moderator MVP
In your validation() function, you've got duplicate code using the same variable as an index which will cause problems. The code looks very messy with brackets all over the place, but it could be replaced by accessing the element using its ID.
Frinavale 9,735
Recognized Expert Moderator Expert
You are going to have to get the ClientID of the TextBox in your VB or C# code.
Once you have that, you're going to have to set the button's onclick attribute to the JavaScript method (which is rather messy, with duplicate code, as acoder has pointed out).
I'm not sure when your button is visible since there are multiple buttons in your code...so... hrmmm
Say your TextBox and Button are made available during RowEditing. In your RowEditing event you would retrieve the ClientID of the TextBox using the FindControl method on the row being edited and then set the onclick attribute of the Button (which you will also have to get using the FindControl method) to call the JavaScript method...passin g it the value of your TextBox's ClientID: -
Private Sub myGridView_RowEditing(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.GridViewEditEventArgs) Handles myGridView.RowEditing
-
Dim theRowBeingEdited As GridViewRow = myGridView.Rows(e.NewEditIndex)
-
Dim myTextBox As TextBox = CType(theRowBeingEdited.FindControl("theTextBox"), TextBox)
-
Dim myButton As Button = CType(theRowBeingEdited.FindControl("theButton"), Button)
-
-
If myTextBox IsNot Nothing AndAlso myButton IsNot Nothing Then
-
myButton.Attributes.Add("onclick", "return JavaScriptFunctionName('" + myTextBox.ClientID + "');")
-
End If
-
End Sub
-
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Walter |
last post by:
I have a GridView using Template columns. In my EditItemTemplate I am using
CompareValidators to check data types. When validation fails, I would like to
change the border of the textbox in question.
I thought I could loop through the ValidatorCollection during the
RowUpdating event but couldn't get the reference to the textbox. When I made
an explicit reference to a textbox I got the message that this would need to
be done in the...
|
by: Buddy Ackerman |
last post by:
I don't know what the problem is. I have a form with several controls that
need to be validated, I put a validation group in every form control, every
validatoino control, the submit button and the validation summary control.
I want it to do client side validation so I set every validation control
display property to none and set the validation summary control to
ShowMessage to true and ShowSummary to false. Als form controls set...
|
by: KenLee |
last post by:
I use asp 2.0 net.
what is the same for "onblur" in asp control such as "<asp:textbox / >"?
I use "<asp:textbox />" inside Gridview.
I try to validation using client side.
when I try using "<input type="text" />" then validation is not hard thing.
however using asp.net is hard.
|
by: Dabbler |
last post by:
I need to insure that at least one of three phone number fields has a value
(requiredfield) but I'm not sure of a way to implement this without server
side logic. Is there a way to use the validation controls to do this?
Thanks.
|
by: JaM |
last post by:
Hi all,
I have created a gridview vith dynamic textbox columns (they are in
variable number, it depends on what things I select from database)
aspx code:
__________________________________________
<asp:GridView AutoGenerateColumns="false" ID="GridView2" Runat="server"
<Columns>
| |
by: naasirsom |
last post by:
Dear sir,
I am using Gridview asp.net 2.0, I have a problem with Gridview Footer Template.
I have put Button, Textbox and RequiredValidator in the Footer Template and Want to validate the textbox if it is empty and I used ValidationGroup . I have done all jobs and the page is working but the problem is the button is working the first time but the second time does not postback.
|
by: Bhagyasree |
last post by:
Hi,
I want to validate the textbox value in the gridview while updating gridview.Iam using Link buttons to edit,update and delete.Iam not getting how to get the updated value of textbox using javascript.Iam adding attributes to the link button update.plz anybody give solution to my problem
|
by: btreddy |
last post by:
Hii Experts,
im facing a problem with the javascript validation.i've a gridview in my web form and added a footer tempalte and placed textboxes in tht tempalte ,just to add a new row to the gridview and i wanna to validate the emalid entered in the footertextbox of the gridview. so i added a javasript function :
function OnCheckEmailID(srcID)
{
var email=document.getElementById(srcID);
var filter...
|
by: parshupooja |
last post by:
hey all,
I have DataTable binded to Gridview . This Datatable contains Data from Database. Before binding it to Gridview I am adding extra line with few controls dynamically in it such as text box below. When page loads I see extra Text box on the bottom of gridview but Validation is not working. Any Idea?
I am calling this Function on each page load.
Private Sub AddControls()
Dim con As SqlConnection = New...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it.
First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
|
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
| |
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own....
Now, this would greatly impact the work of software developers. The idea...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |