Click here to Skip to main content
15,890,438 members
Home / Discussions / ASP.NET
   

ASP.NET

 
GeneralRe: MVC Newbie Question - Controller and View - page not found Pin
jkirkerx13-Feb-15 7:31
professionaljkirkerx13-Feb-15 7:31 
QuestionHow to retrieve data from a remote desktop database via REST API Pin
IsoftTech11-Feb-15 4:07
IsoftTech11-Feb-15 4:07 
AnswerRe: How to retrieve data from a remote desktop database via REST API Pin
Afzaal Ahmad Zeeshan11-Feb-15 4:49
professionalAfzaal Ahmad Zeeshan11-Feb-15 4:49 
GeneralRe: How to retrieve data from a remote desktop database via REST API Pin
IsoftTech11-Feb-15 23:28
IsoftTech11-Feb-15 23:28 
AnswerRe: How to retrieve data from a remote desktop database via REST API Pin
Afzaal Ahmad Zeeshan12-Feb-15 3:08
professionalAfzaal Ahmad Zeeshan12-Feb-15 3:08 
Questionerror while updating the ms access data base after hosting the site on domain Pin
Member 1100557011-Feb-15 3:35
Member 1100557011-Feb-15 3:35 
AnswerRe: error while updating the ms access data base after hosting the site on domain Pin
Richard Deeming11-Feb-15 4:18
mveRichard Deeming11-Feb-15 4:18 
QuestionJavascript inside updatepanel cannot access server side variable after potback Pin
Moodhi10-Feb-15 11:40
Moodhi10-Feb-15 11:40 
My ASP.NE Test Page is as follows:

TestPage.aspx:

<%@ Page Language="VB" MasterPageFile="~/Site.master" AutoEventWireup="false" CodeFile="TestPage.aspx.vb" Inherits="TestPage" title="Test Page"%>
<%@ Register assembly="AjaxControlToolkit" namespace="AjaxControlToolkit" tagprefix="asp" %>

<asp:content id="Content1" contentplaceholderid="MainContent" runat="Server">

<asp:toolkitscriptmanager id="ToolkitScriptManager1" runat="server">



Test Page



<asp:updatepanel id="UpdatePanel1" runat="server" updatemode="Conditional">

<contenttemplate>



<asp:textbox id="txtAddress" runat="server" height="16px" width="200px"><input id="btnSelect" type="button" value="Select" onclick="AddTextBox();" />



<asp:button id="btnSave" runat="server" text="Save">






<script type="text/javascript">
function GetDynamicTextBox(textboxValue) {

//alert('Debug 01' + textboxValue);
var width = document.getElementById("ctl00_MainContent_txtAddress").style.width;
return "<input name = 'Text1' type='text' value = '" + textboxValue + "' style='width:" + width + "';/>"
//alert('Debug 02' + width);
}

function AddTextBox() {

var thisAdd = document.getElementById("ctl00_MainContent_txtAddress");

if (thisAdd.value == 0) return false;

var div = document.createElement('DIV');
div.innerHTML = GetDynamicTextBox(document.getElementById("ctl00_MainContent_txtAddress").value);
document.getElementById("targetDiv").appendChild(div);
document.getElementById("ctl00_MainContent_txtAddress").value = '';
}

function RecreateDynamicTextboxes() {
var txtValues = eval('<%=TxtValues%>');
alert('Debug 02: ' + txtValues);

if (txtValues != null) {
var html = "";
for (var i = 0; i < txtValues.length; i++) {
html += "
" + GetDynamicTextBox(txtValues[i]) + "
";
}
document.getElementById("targetDiv").innerHTML = html;
}
}

function pageLoad() {
RecreateDynamicTextboxes();
}
</script>





Now Code Behind (TestPage.aspx.vb) is as follows:

Imports System.Data.SqlClient
Imports System.Web.Script.Serialization

Partial Class TestPage

Inherits System.Web.UI.Page

Protected TxtValues As String

Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load

End Sub


Protected Sub btnSave_Click(sender As Object, e As EventArgs) Handles btnSave.Click

Dim serializer As New JavaScriptSerializer()
Dim textboxValues As String() = Request.Form.GetValues("Text1")
Me.TxtValues = serializer.Serialize(textboxValues)

End Sub

End Class

If I remove "UpdatePanel" and then run it, enter some text in the textbox, click "select" and do this for a few lines and finally click "Save", the PostBack returns the text lines entered.

But when I add "UpdatePanel" back in then it fails on line:

var txtValues = eval('<%=TxtValues%>'); of javascript "function RecreateDynamicTextboxes()" i.e. TxtValues contains nothing after PostBack.

Can I request if someone can suggest ways to make this work please?
mbmirza

AnswerRe: Javascript inside updatepanel cannot access server side variable after potback Pin
jkirkerx10-Feb-15 13:21
professionaljkirkerx10-Feb-15 13:21 
GeneralRe: Javascript inside updatepanel cannot access server side variable after potback Pin
Moodhi12-Feb-15 11:32
Moodhi12-Feb-15 11:32 
GeneralRe: Javascript inside updatepanel cannot access server side variable after potback Pin
jkirkerx12-Feb-15 12:45
professionaljkirkerx12-Feb-15 12:45 
QuestionPrevent Validation From Normal HTML Controls Pin
Dominick Marciano10-Feb-15 8:32
professionalDominick Marciano10-Feb-15 8:32 
AnswerRe: Prevent Validation From Normal HTML Controls Pin
Richard Deeming10-Feb-15 10:17
mveRichard Deeming10-Feb-15 10:17 
AnswerRe: Prevent Validation From Normal HTML Controls Pin
jkirkerx10-Feb-15 13:27
professionaljkirkerx10-Feb-15 13:27 
QuestionAccess a function in user control from a aspx page Pin
ranjithkumark8-Feb-15 12:45
ranjithkumark8-Feb-15 12:45 
AnswerRe: Access a function in user control from a aspx page Pin
Richard Deeming9-Feb-15 2:54
mveRichard Deeming9-Feb-15 2:54 
AnswerRe: Access a function in user control from a aspx page Pin
loben325-Feb-15 2:30
loben325-Feb-15 2:30 
QuestionVideo Calling Pin
Member 110844697-Feb-15 10:03
Member 110844697-Feb-15 10:03 
AnswerRe: Video Calling Pin
Richard MacCutchan7-Feb-15 22:14
mveRichard MacCutchan7-Feb-15 22:14 
AnswerRe: Video Calling Pin
ZurdoDev9-Feb-15 4:58
professionalZurdoDev9-Feb-15 4:58 
QuestionUsing a linq in aspx Pin
Member 110844697-Feb-15 9:59
Member 110844697-Feb-15 9:59 
AnswerRe: Using a linq in aspx Pin
Richard Andrew x647-Feb-15 10:55
professionalRichard Andrew x647-Feb-15 10:55 
AnswerRe: Using a linq in aspx Pin
Richard MacCutchan7-Feb-15 22:13
mveRichard MacCutchan7-Feb-15 22:13 
AnswerRe: Using a linq in aspx Pin
ZurdoDev9-Feb-15 5:00
professionalZurdoDev9-Feb-15 5:00 
QuestionHow to export data from textbox and RichTextbox from Asp.net to Msword Templete Form? Pin
Member 85878306-Feb-15 20:37
Member 85878306-Feb-15 20:37 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.