It gives me waring stating "runat" missing in asp:textbox. If i give runat then I can't use <%= %> tag.
What should I do and how to work out with such things?
I need help regarding this at the earliest. Any help is appreciative. Kindly help me woth any good tutorial for ASP.NET. I looked around, but couldn't find anything good enuogh that can solve my queries easily.
I can achieve the same using <input> of HTML. But for that I will have to validate in javascript. I already have all validations in asp.vb file (I had done to add records. This is to View and Update). And I can't see any way to access input fields in asp.vb
file.
If we can't use scriptlets, expressions in such conditions then what is the use of expressions. Additionally, asp.textbox got to have runat tag and with runat tag any scriptlets can't be used?
What can be the solution? Am I doing something wrong?
If we can't use scriptlets, expressions in such conditions then what is the use of expressions. Additionally, asp.textbox got to have runat tag and with runat tag any scriptlets can't be used?
What can be the solution? Am I doing something wrong?
Have you tried to add it in between the asp:textbox as its working with input tag why its not working in server tag it should work check else post your class file and relevant code on html,codebehind let me check..
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
task = Request.QueryString("Task").Trim.ToUpper
If (task <> "V" And task <> "U") Then
MsgBox("Invalid Task! No Access")
Response.Redirect("Default.aspx", True)
Else
TaskLbl.Text = task
empObj = New EmployeeClass()
empObj.EmployeeName = "Dave"
'empObj = GetEmployee()
End If
End Sub
****************************
' THE CLASS
public class EmployeeClass
private empNameas String
Public Property EmployeeName() As String
Get
Return empName
End Get
Set(ByVal value As String)
empName = value
End Set
End Property
End class
You can see how differnt ways I have used to achieve the goal. When you run this code, you will be surprised to see the results in input text box. This is usually I used to program in JSP and things used to work excellently.
Try it. Haven't you ever used such a thing in this way. If not, then how do you work with displaying data in textboxes? Maybe other technique can help me work out that way.
Try it. Haven't you ever used such a thing in this way. If not, then how do you work with displaying data in textboxes? Maybe other technique can help me work out that way.
Why can't you try this
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
task = Request.QueryString("Task").Trim.ToUpper
If (task <> "V" And task <> "U") Then
MsgBox("Invalid Task! No Access")
Response.Redirect("Default.aspx", True)
Else
TaskLbl.Text = task
empObj = New EmployeeClass()
empObj.EmployeeName = "Dave"
empNameTxt.Text=empObj.EmployeeName;
'empObj = GetEmployee()
End If
End Sub
jassi_tkm
Member
4 Points
12 Posts
Access an object in Scriptlets
Jul 22, 2009 01:45 PM|LINK
Hello,
I am new to ASP.NET development.
I want to retrieve an object from the module and use it in scriplets. Basically its to show the data of the object. Something like :
<form>
<%
dim obj as Employee = GetEmployee() ' Method in Module
%>
<asp:textbox .... text=<%=obj.EmpID%>
<asp.textbox .... text=<%=obj.Name%>
...
<
This is what I tried:
asp:TextBox ID="empNameTxt" Width="211px" ReadOnly="True" Text="<%=empObj.EmployeeName%>"></asp:TextBox>It gives me waring stating "runat" missing in asp:textbox. If i give runat then I can't use <%= %> tag.
What should I do and how to work out with such things?
I need help regarding this at the earliest. Any help is appreciative. Kindly help me woth any good tutorial for ASP.NET. I looked around, but couldn't find anything good enuogh that can solve my queries easily.
Thanks
venkatu2005
All-Star
32487 Points
6742 Posts
Re: Access an object in Scriptlets
Jul 23, 2009 07:10 AM|LINK
try this
<asp:TextBox ID="empNameTxt" Width="211px" ReadOnly="True" Text='<%= empObj.EmployeeName%>'></asp:TextBox>
Thanks.
jassi_tkm
Member
4 Points
12 Posts
Re: Access an object in Scriptlets
Jul 23, 2009 08:07 AM|LINK
No Venkatu, No Success.
I can achieve the same using <input> of HTML. But for that I will have to validate in javascript. I already have all validations in asp.vb file (I had done to add records. This is to View and Update). And I can't see any way to access input fields in asp.vb file.
If we can't use scriptlets, expressions in such conditions then what is the use of expressions. Additionally, asp.textbox got to have runat tag and with runat tag any scriptlets can't be used?
What can be the solution? Am I doing something wrong?
venkatu2005
All-Star
32487 Points
6742 Posts
Re: Access an object in Scriptlets
Jul 23, 2009 09:39 AM|LINK
Have you tried to add it in between the asp:textbox as its working with input tag why its not working in server tag it should work check else post your class file and relevant code on html,codebehind let me check..
Thanks.
jassi_tkm
Member
4 Points
12 Posts
Re: Access an object in Scriptlets
Jul 23, 2009 11:09 AM|LINK
Hello,
HTML Code
<tr> <td class="style2"> Employee Name</td> <td> <asp:TextBox ID="empNameTxt" runat="server" Width="211px" ReadOnly="True" Text=''> <%= empObj.EmployeeName%> </asp:TextBox> </td> </tr> <tr> <td class="style2"> Address </td> <td> <input id="Text1" type="text" value="<%= empObj.EmployeeName%>" size="20" /><br /> <asp:TextBox ID="addressTxt" runat="server" Width="125px" Text='<%= empObj.EmployeeName%>'></asp:TextBox> </td> </tr>Cde Behind
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load task = Request.QueryString("Task").Trim.ToUpper If (task <> "V" And task <> "U") Then MsgBox("Invalid Task! No Access") Response.Redirect("Default.aspx", True) Else TaskLbl.Text = task empObj = New EmployeeClass() empObj.EmployeeName = "Dave" 'empObj = GetEmployee() End If End Sub **************************** ' THE CLASS public class EmployeeClass private empNameas String Public Property EmployeeName() As String Get Return empName End Get Set(ByVal value As String) empName = value End Set End Property End classYou can see how differnt ways I have used to achieve the goal. When you run this code, you will be surprised to see the results in input text box. This is usually I used to program in JSP and things used to work excellently.
Try it. Haven't you ever used such a thing in this way. If not, then how do you work with displaying data in textboxes? Maybe other technique can help me work out that way.
Regards,
venkatu2005
All-Star
32487 Points
6742 Posts
Re: Access an object in Scriptlets
Jul 23, 2009 12:05 PM|LINK
Why can't you try this
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load task = Request.QueryString("Task").Trim.ToUpper If (task <> "V" And task <> "U") Then MsgBox("Invalid Task! No Access") Response.Redirect("Default.aspx", True) Else TaskLbl.Text = task empObj = New EmployeeClass() empObj.EmployeeName = "Dave" empNameTxt.Text=empObj.EmployeeName; 'empObj = GetEmployee() End If End SubThanks.
bhupiyujuan
Member
319 Points
90 Posts
Re: Access an object in Scriptlets
Jul 23, 2009 01:36 PM|LINK
try this
Regards
BY