I am calling javascript function from anchor tag. But problem is i am rendering anchor tag from code rendering block. From here i am fetching a value from database and sending to the function as a parameter. My code is:
<div>
<%----%>
<ul>
<%
if (_dsContent.Tables.Count == 0)
return;
System.Collections.Generic.List<string> lstCat =
new System.Collections.Generic.List<string>();
foreach (System.Data.DataTable table in _dsContent.Tables)
{
foreach (System.Data.DataRow row in table.Rows)
{
if (String.IsNullOrEmpty(Convert.ToString(row["ContentPart"])))
{
if (Convert.ToString(row["Content"]).Length > 200)
content = Convert.ToString(row["Content"]).Substring(0, 200);
else
content = Convert.ToString(row["Content"]);
}
else
{
if (Convert.ToString(row["ContentPart"]).Length > 200)
content = Convert.ToString(row["ContentPart"]).Substring(0, 200);
else
content = Convert.ToString(row["ContentPart"]);
}
string catStr = Convert.ToString(row["categoryString"]);
string[] arrayCat = new string[2];
if (!String.IsNullOrEmpty(catStr))
{
arrayCat = catStr.Split(',');
}
if (!String.IsNullOrEmpty(content))
{
if (!lstCat.Contains(arrayCat[1]))
{
Response.Write("<div style="color:Red; font-weight:<br mode="hold" /> bold;font-size:20px">" + arrayCat[1] + "</div>");
lstCat.Add(arrayCat[1]);
}
Response.Write("<li>");
Response.Write("<div style="background-<br mode="hold" /> color:#DFD48D">Posted On - " + row["InsertionDate"] + "</div>");
Response.Write("<div style="font-weight: bold;text-<br mode="hold" /> align:justify">'" + row["Header"] + "'</div>");
Response.Write("<div style="font-size: small">Date - '" + row["Date"] + "'</div>");
Response.Write("<div style="text-align:justify">");
Response.Write(content);
string jud = Convert.ToString(row["Content"]);
Response.Write("");
Response.Write("
<a href='#' runat="server" önclick=ShowContent()>");
Response.Write("Read More...");
Response.Write("");
Response.Write("</div>");
Response.Write("</li>");
}
}
}
%>
</string></string></ul>
</div>
here i am not able to send string jud as parameter. my javascript function is
<script language="javascript" type="text/javascript">
function ShowContent(jud) {
PageMethods.ShowContent(jud,Success, Failure);
}
function Success(result) {
window.open('showcontent.aspx', null,'left=200, top=30, height=550, width= 500,
status=no, resizable= yes, scrollbars= yes,toolbar= no,location= no, menubar=
no');
}
function Failure(error) {
alert(error);
}
</script>