This is a migrated thread and some comments may be shown as answers.

[Solved] Client Side access to the control inside Radgrid

7 Answers 216 Views
Grid
This is a migrated thread and some comments may be shown as answers.
John Yu
Top achievements
Rank 1
John Yu asked on 18 Apr 2008, 12:16 PM
Hi All,

I have a scenario, in this i have a radgrid with templatecolumn,
within the column i have a link which on click opens a radtooltip
Inside the tooltip i have a radpanelbar which has two controls one is a link and other is a textbox
I want javascript code for populating the textbox with hidden field value  with "onclick" event of the link button.
i dont want any page refresh

I found difficulty in accessing the radgrid controls via javascript

Help Please,

Thanks in advance

7 Answers, 1 is accepted

Sort by
0
Nikita Gourme
Top achievements
Rank 1
answered on 21 Apr 2008, 12:54 PM
If you want to pass data from the clicked row in the grid to the controls inside the tooltip, see the approach with RadWindow presented here. I suppose that logic like this can be utilized to populate the textbox inside the tooltip with javascript code. Of course, it may vary depending on the location of the textbox and the link button inside the panelbar control.

Nikita

0
John Yu
Top achievements
Rank 1
answered on 21 Apr 2008, 02:15 PM
Thank u for ur reply
in the example given by you i found the rows are updated all at once
but i need only one textbox in one column should be updated with click on the link
0
Nikita Gourme
Top achievements
Rank 1
answered on 21 Apr 2008, 02:19 PM
See the discussion in this forum thread for more info on the matter. Hope it will be helpful to you.

Nikita
0
Richard
Top achievements
Rank 1
answered on 21 Apr 2008, 08:12 PM
Hi John,

I would try something along these lines...

In the ItemCreated event of your grid, grab the ClientIDs of your controls and use them to build the script and assign it to the OnClick of your button:

protected void myRadGrid_ItemCreated(object sender, GridItemEventArgs e)
{
    if (e.Item is GridEditableItem && e.Item.IsInEditMode)
    {
        string myHiddenValue = myHiddenField.value;
        string myJavaScript = "javascript:document.getElementById('" + myTextBox.ClientID + "').value = " + myHiddenvalue + ";return false;";
        myLinkButton.OnClientClick = myJavaScript;
    }
}

Note:  This is just to give an idea.  Depending on your setup you may need to use e.Item to get a handle on your controls.  You also need to remember to set the OnItemCreated property of the grid to point to the handler.
0
John Yu
Top achievements
Rank 1
answered on 28 Apr 2008, 03:20 PM
Hi richard
Thank u for ur help

I did this code in itemcreated event of the radgrid

Javascript = Javascript +

" document.getElementById('" + txtEditpassword.ClientID + "').value = " + HFPwd.ClientID + ".value; return false;";

Then i put this as 

Linkbutton.OnClientClick = Javascript;

I got working in IE but in mozilla it refreshes when i click that linkbutton
i tried with converting linkbutton with hyperlink but the result is same
when there is change is two browsers
ultimately i need two browsers to behave the same way

Need help

Thanks

0
Richard
Top achievements
Rank 1
answered on 28 Apr 2008, 03:37 PM
Hi John,

There are a couple of things you can try.  Mozilla apparently likes the "return false;" to be in front of everything else, so you could try something like:

string myJavaScript = "javascript:return false;document.getElementById('" + myTextBox.ClientID + "').value = " + myHiddenvalue + ";";

If that doesn't work you could use the link button idea but set PostBackUrl="javascript:void(0)"

[Edited for correctness:  LinkButton has postbackUrl, not href]
0
John Yu
Top achievements
Rank 1
answered on 29 Apr 2008, 10:36 AM
Thank u Richard

It worked fine and i can populate the textbox now in both IE and mozilla

Great Work
Tags
Grid
Asked by
John Yu
Top achievements
Rank 1
Answers by
Nikita Gourme
Top achievements
Rank 1
John Yu
Top achievements
Rank 1
Richard
Top achievements
Rank 1
Share this question
or