mrjimoy_05 0 Newbie Poster

I have the code below to show the modal-box after a LinkButton clicked. And, what I want to do is how to assign the Textbox value on the modal-box from the javascript.

I have a gridview:

<asp:GridView ID="GV1" runat="server" DataSourceID="DS1" >
    <Columns>
        <asp:TemplateField ShowHeader="False">
            <ItemTemplate>
                <asp:LinkButton ID="LinkButton" runat="server" CausesValidation="False" >
                </asp:LinkButton>
            </ItemTemplate>
        </asp:TemplateField>
    </Columns>
</asp:GridView>

Code-behind:

'Attach a Javascript funtion to the LinkButton. 
Dim myLinkButton As LinkButton
For i As Integer = 0 To GV1.Rows.Count - 1
    myLinkButton = DirectCast(GV1.Rows(i).Cells(1).FindControl("LinkButton"), LinkButton)
    myLinkButton.Attributes.Add("onclick", "shopModalPopup('" + .Rows(i).Cells(0).Text & "'); return false;") '--> Passing the value
Next

Then the Javascript:

<script>
function shopModalPopup(id){
//show the modal-box
    $("#dialog-form").dialog("open");
    // ---> How to assign the 'id' value to the Textbox1 on the modalbox?
} 

$(function () {
    $("#dialog-form").dialog({
        autoOpen: false,
        height: 300,
        width: 350,
        modal: true
    });
});
</script>

And below is the code for the modal-box:

<div id="dialog-form" title="Modal Box">
    <input type="text" id="Textbox1" />
</div>

How to take the value passed from function to the label on the box? I've tried using document.getElementById(Textbox1).value = id; but it doesn't work and even reload the page that cause the modal-box disappear. Thank you.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.