Visual Basic .NET » ASP.NET General Discussion






then the script block:

--- script type="text/javascript"

function strToUppercase(){
Matteo.Web.AtlasMusicArchiver.Admin.Prova.StrToUppercase(strToUppercase_callback);
}

function strToUppercase_callback(res)
{
if (res.value==null){
alert(res.error);
return;
}

var resultDiv = document.getElementById('resultText');
if (resultDiv.firstChild)
resultDiv.removeChild(resultDiv.firstChild);
resultDiv.appendChild(document.createTextNode(res.value));
}
--- /script
in the .CS file of the aspx page:


public string StrToUppercase()
{
string _result = TE_Word.Text;
return _result;
}
Well, after invoking the function, into my tag, it prints NULL.
So, is it possible to access a TextBox runat="server" (string _result =
TE_Word.Text;)
to get its value?
I hope it's all clear, thanks and regards

interpeo









-- cs --

protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
ltrLoadScript.Text = " \n";

}
}


public string StrToUppercase(TE_WordValue)
{
string _result = TE_WordValue;
return _result;
}
Hope this help

Lawson

On 7/7/06, interpeo wrote:


Hi everybody,

I tried a simple test with AJAX in ASP.NET page, here is my code:

...






then the script block:

--- script type="text/javascript"

function strToUppercase(){
Matteo.Web.AtlasMusicArchiver.Admin.Prova.StrToUppercase
(strToUppercase_callback);
}

function strToUppercase_callback(res)
{
if (res.value==null){
alert(res.error);
return;
}

var resultDiv = document.getElementById('resultText');
if (resultDiv.firstChild)
resultDiv.removeChild(resultDiv.firstChild);
resultDiv.appendChild(document.createTextNode(res.value));
}
--- /script
in the .CS file of the aspx page:


public string StrToUppercase()
{
string _result = TE_Word.Text;
return _result;
}
Well, after invoking the function, into my tag, it prints NULL.
So, is it possible to access a TextBox runat="server" (string _result =
TE_Word.Text;)
to get its value?
I hope it's all clear, thanks and regards

interpeo
>


 







====== script

function strToUppercase()
{
var textBox = document.getElementById('TE_Word');

Matteo.Web.AtlasMusicArchiver.Admin.Prova.StrToUppercase(textBox.value,strToUppercase_callback);

}
function strToUppercase_callback(res)
{
if (res.error != null)
{
alert(res.error);
return;
}

//alert(res.value);

printDiv('resultText',res);
}

//DIV or SPAN tag...
function printDiv(theDiv,theAjaxResponse)
{
var resultDiv = document.getElementById(theDiv);
if (resultDiv.firstChild)
resultDiv.removeChild(resultDiv.firstChild);
resultDiv.appendChild(document.createTextNode(theAjaxResponse.value));
}

====== /script

then...
====== .cs

public string StrToUppercase(string myString)
{
string _result = myString.ToUpper(); // sorry, I forgot the method ToUpper() last time
return _result;
}
well, very simple after all... after your help, and after I understood it!

thank you again, bye

interpeo

AJAX test with ASP.NET -- interpeo --


Hi everybody,

I tried a simple test with AJAX in ASP.NET page, here is my code:

...
Insert a word Width="160px">
-- "Zihotki --


You shoud use JS t get a value and pass it to server like this:

function strToUppercase(){
var textbox = document.getElementById(TE_Word);
Matteo.Web.AtlasMusicArchiver.Admin.Prova.StrToUppercase(textbox.value,
strToUppercase_callback);

}
and in the .CS file of the aspx page:


public string StrToUppercase(string text)
{
string _result = text+", hello from server";
return _result;

}

ASP.Net components are not accessible from AjaxPro methods because page life cycle is not occur.

-- lawson law --

interpeo,

just include a parameter for your strToUppercase() like this strToUppercase(TE_WordValue)
Where TE_WordValue is the value for TE_Word. The trick is you should generate TE_WordValue in the Page_Load routine of your cs file.

-- Js ---
function strToUppercase(TE_WordValue){
Matteo.Web.AtlasMusicArchiver.Admin.Prova.StrToUppercase(TE_WordValue,
strToUppercase_callback);
}

-- Web form
Insert a word Width="160px">
Insert a word Width="160px">
-- interpeo --


ok Zihotki and Lawson thanks a lot, I'll try your suggests and will let u know.

interpeo

-- interpeo --


Hi,

ok, I solved the issue with the following code, and it works!
====== .aspx file

...
Insert a word Width="160px"> onclick="strToUppercase()" />
[Submit Comment]Home