PDA

View Full Version : [CLOSED] TextField.Text is empty in OnDirectClick



supera
Feb 08, 2012, 1:53 PM
Hi!

I made a small example to explain my question!

1 - In page_load, I set a value to text property of txtContextID control.
2 - In btnShow_Click (called by OnDirectClick event from button btnShow) i try show the value of Text property of txtContextID. But this value return empty.

This is a problem or am I doing something wrong?
Thanks for any help!



<%@ Page Language="vb" AutoEventWireup="false" CodeBehind="Test1.aspx.vb" Inherits="WebApplication3.Test1" %>
<%@ Register Assembly="Ext.Net" Namespace="Ext.Net" TagPrefix="ext" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">

<script runat="server">

Protected Sub Page_Load(sender As Object, E As EventArgs) Handles Me.Load

If (Not ExtNet.IsAjaxRequest) Then
txtContextID.Text = "12345"
End If

End Sub

Private Sub btnShow_Click(sender As Object, e As DirectEventArgs)
Dim mb As Ext.Net.MessageBox = New Ext.Net.MessageBox

mb.Alert("txtContextID.Text value!", "txtContextID.Text is: " & txtContextID.Text)
mb.Show()

End Sub

</script>

<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<ext:ResourceManager ID="resManagerSGCO" runat="server" Namespace="SuperaWeb.SGCO" />
<ext:Panel runat="server" ID="panel1" Title="Test of OnDirectClick!" Layout="FitLayout" Flex="1">
<TopBar>
<ext:Toolbar runat="server" ID="ctl61">
<Items>
<ext:Button runat="server" id="btnShow" Icon="Add" Text="Show txtContextID.Text value" OnDirectClick="btnShow_Click" />
</Items>
</ext:Toolbar>
</TopBar>
<Items>
<ext:TextField runat="server" ID="txtContextID" Text="" />
</Items>
</ext:Panel>
</body>
</html>

Vladimir
Feb 08, 2012, 1:56 PM
Hi,

You have no ASP.NET form therefore there is no submit of field values. Add form tag for automatic submit

supera
Feb 08, 2012, 2:05 PM
Hi Vladimir.

You're right!

I inserted the tag <form> in the aspx page and it worked correctly.

Thanks a lot for your help.