?
Solved

Unable to retrieve div innerHTML value using server side code

Posted on 2006-11-27
3
Medium Priority
?
2,755 Views
Last Modified: 2008-01-09
Dear all,
            I am using C# web form. I am storing some value from data base to my div tag on page load. I update div value using java script . Finally I want to validate the update value in the server side. I am unable to get updated value in the server side. Can anyone help me to solve the problem.

CODE

<DIV id="sc_lbEmpCurCount" style="DISPLAY: inline; WIDTH: 70px; HEIGHT: 15px" runat="server"
            ms_positioning="FlowLayout"></DIV>

Page load server side code
sc_lbEmpCurCount.InnerHtml = iShowCount.ToString();  

using javasript i Update the value

Server Side code
iCurrCount = Convert.ToInt32(sc_lbEmpCurCount.InnerHtml); // I am getting intial value but I want update value




0
Comment
Question by:cosKarthik
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 3

Accepted Solution

by:
jay_gadhavi earned 375 total points
ID: 18025644
Try this

I give u an example to solve the problem : it's work perfectly

Html and Javascript



<%@ Page Language="VB" AutoEventWireup="false" CodeFile="DivProblem.aspx.vb" Inherits="DivProblem" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<script language="javascript">
function callme()
{
alert(document.getElementById("sc_lbEmpCurCount").innerHTML);
document.getElementById("sc_lbEmpCurCount").innerHTML=""
document.getElementById("sc_lbEmpCurCount").innerHTML="hello from inner html";
document.getElementById("text1").value=document.getElementById("sc_lbEmpCurCount").innerHTML
alert(document.getElementById("sc_lbEmpCurCount").innerHTML);
}

</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
    <title>Untitled Page</title>
</head>
<body>
    <form id="form1" runat="server">
   
    <button id="butt1" name="butt1" value="click Here" runat=server onclick="javascript:callme();" ></button>
   
    <DIV id="sc_lbEmpCurCount" style="DISPLAY: inline; WIDTH: 70px; HEIGHT: 15px" runat="server"  ms_positioning="FlowLayout">
    jayendra
    </DIV>
    <input type=text value="jay" name="hello" id="text1" runat="server"  />
        </form>
</body>
</html>



Server side code :


Partial Class DivProblem
    Inherits System.Web.UI.Page
    Public ishowcount = 29
    Public iCurrCount = 0

    Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
        If Not IsPostBack Then
            sc_lbEmpCurCount.InnerHtml = ishowcount.ToString()
            text1.Value = sc_lbEmpCurCount.InnerHtml
        End If

    End Sub
    Public Sub shouwcount()
        iCurrCount = Convert.ToInt32(sc_lbEmpCurCount.InnerHtml) ' // I am getting intial value but I want update value
    End Sub

    Protected Sub butt1_ServerClick(ByVal sender As Object, ByVal e As System.EventArgs) handles butt1.ServerClick
        text1.Value = sc_lbEmpCurCount.InnerHtml
    End Sub
End Class

Regards,
jay

0
 
LVL 3

Expert Comment

by:jay_gadhavi
ID: 18025678
If u want the innerhtml value then dont call the butt1_serverclick method (with deleteling the handles or whole method)
0
 

Author Comment

by:cosKarthik
ID: 18026025
I have used hidden control instead of text box
0

Featured Post

Enroll in August's Course of the Month

August's CompTIA IT Fundamentals course includes 19 hours of basic computer principle modules and prepares you for the certification exam. It's free for Premium Members, Team Accounts, and Qualified Experts!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Having worked on larger scale sites, we found out that you are bound to look at more scalable solutions to integrating widgets, code snippets or complete applications and mesh them into functional sites, in any given composition. To share some of…
This article demonstrates how to create a simple responsive confirmation dialog with Ok and Cancel buttons using HTML, CSS, jQuery and Promises
The viewer will learn the basics of jQuery, including how to invoke it on a web page. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery.: (CODE)
The viewer will learn the basics of jQuery including how to code hide show and toggles. Reference your jQuery libraries: (CODE) Include your new external js/jQuery file: (CODE) Write your first lines of code to setup your site for jQuery…
Suggested Courses

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question