0

I am using a asp.net web application. In that Application I am having one text box in a web page to get inputs from user. Now I need to read the value in HTML source page as I have mentioned below.

 <a href="" onclick="editDocumentWithProgID2('textbox1.text', '', 'SharePoint.OpenDocuments', '0', 'http://demo-1/blankpage', '0')">Edit onclick</a>

In the above line I am not able to get the textbox1 value. I need to pass the textbox value as dynamically. How can I do this ? What I need to change in this code? Please help me on this. Thanks.

2
  • Can you show the markup for textbox? Commented Aug 28, 2013 at 11:09
  • instead of struggling like this you can use jquery function and possibly can do it there. Commented Aug 28, 2013 at 11:27

2 Answers 2

1

You can use scriptlet to get ClientID if the ClientIDMode of TextBox is not static. You can use document.getElementById to get the DOM object for your TextBox control

onclick="editDocumentWithProgID2(document.getElementById('<%= textbox1.ClientID %>').value, '0', 'http://demo-1/blankpage', '0')">Edit onclick</a>

Or you can call a function (parameterless) from onclick and call editDocumentWithProgID2 from that function to make the call more readable.

Html

<a href="" onclick="someFun();" > Edit onclick</a>

Javascript

function someFun()
{
    editDocumentWithProgID2(document.getElementById('<%= textbox1.ClientID %>').value,, '0', 'http://demo-1/blankpage', '0'); 
}
Sign up to request clarification or add additional context in comments.

Comments

0

Try document.getElementById to get the exact element id.

 <a href="" onclick="editDocumentWithProgID2(document.getElementById('<%= textbox1.ClientID %>').value >Edit onclick</a>

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.