Click here to Skip to main content
15,921,959 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +
Hello. I have one authoring software from which I am fetching value using Request.Form[] of asp.net. Value is fetched succesfully. But then I want to show the value in a asp.net Label. How to do it using javascript? Kindly instruct me, I am new into javascript and learning. I tried to write the below code in my .aspx file.

<asp:Label ID="Label1" runat="server" Text="Label" Font-Size="Larger"></asp:Label>
<script type="text/javascript">
function text()
{
if (document.getElementById("Label1") == "")
{
document.getElementById("Label1")= testname;

}
}
</script>
Posted

You have try like this.
Solution 1 :
============
XML
<script lanugage=javascript runat=server>
function ontextchange()
{
 document.getElementById("lableid").value = "change in text or whatever";
}
</script>


Solution 2 :
============
XML
<script lanugage=javascript runat=server>

function ontextchange()

{

 // check if browser is IE

 if(ie)

 document.getElementById("lableid").innerHTML = "change in text or whatever";

else

 document.all('labelid').innerHTML ="hello word"

}

</script>


Hope this will helpful to you.!
 
Share this answer
 
Comments
JL_Coder 15-Oct-13 3:22am    
Hello. I tried both. But it is not fetching the value from the another software. What I want to do is fetch data from Another software, for which I have written this code.
string testname = Request.Form["TestName"];
so by this, I am getting the value of "Testname" from another software. It is showing successfully while debugging. The value fetched successfully and value is "Test 1". Now, I want to show that value in our "Label1". Writing above code just show "Label1" when I run it.
bjdestiny 15-Oct-13 6:18am    
ok no problem now do one thing that as in above code kindly assign your fetch value to the lable as below.
document.all('labelid').innerHTML = put here your fetch value code
Replace it like below

if (document.getElementById("Label1").value  == "")
{
document.getElementById("lable1").value = "test name";
}


or

if (document.getElementById("Label1").innerHTML == "")
{
document.getElementById("lable1").innerHTML = "test name";
}
 
Share this answer
 
v3
Comments
JL_Coder 15-Oct-13 3:22am    
Hello. I tried both. But it is not fetching the value from the another software. What I want to do is fetch data from Another software, for which I have written this code.
string testname = Request.Form["TestName"];
so by this, I am getting the value of "Testname" from another software. It is showing successfully while debugging. The value fetched successfully and value is "Test 1". Now, I want to show that value in our "Label1". Writing above code just show "Label1" when I run it.
JoCodes 15-Oct-13 3:26am    
You had mentioned in your question that value is fetched successfully??. So that only assignment part have been posted by me as a solution. I have added an if condition to check whether its null as per your code. May I know on which event you are trying to call this JS function?
JL_Coder 15-Oct-13 3:54am    
I meant that when I debug it using f10, line by line, it was showing the value, but after finishing it, it doesn't show the value in label.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900