|
Saam_cse wrote: I like to create textBox dynamically by pressing a button. But I can’t getting the textbox or its value back after a postback occur.
You will not get. Because you have to create the textbox, before Page_Load() , because Postback data and view state data load for control before page_load . Create your control on Page_PreInit() will resolve your problem.
|
|
|
|
|
Create a HashTable and add the control id as key and control value as value.
Then at postback get the control's value using Request.Form(control_id) and create the control again and assign it the same value.
Example :
Protected Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
Try
If Not IsNothing(ViewState("ht")) Then
Dim v_ht As New Hashtable
v_ht = CType(ViewState("ht"), Hashtable)
For i As Integer = 0 To v_ht.Count - 1
'getting value of 1st control
Dim a = Request.Form("txt_1")
'getting value of 2nd control
Dim b = Request.Form("txt_2")
Next
Else
Dim ht As New Hashtable
'dynamically created 1st control
Dim txt As TextBox
txt = New TextBox
txt.ID = "txt_1"
txt.Text = "CODE"
ht.Add(txt.ID, txt.Text)
ph_Main.Controls.Add(txt)
'dynamically created 2nd control
txt = New TextBox
txt.ID = "txt_2"
txt.Text = "PROJECT"
ht.Add(txt.ID, txt.Text)
ViewState("ht") = ht
ph_Main.Controls.Add(txt)
End If
Catch ex As Exception
Response.Write(ex.ToString)
End Try
End Sub
store the id(s) of dynamic controls in a hashtable.
at postback loop through the hashtable and using Request.Form and passing control id through hastabale , get back all values.
this is the easiest method of getting back the values of dynamically created controls.
Regards,
Kapil Thakur
(Where's there is Kapil , there is a way) - thakur.kapil@gmail.com
|
|
|
|
|
Protected Sub btnSave_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles btnSave.Click
TextBox txtBxTemp = (TextBox)e.Item.FindControl("tx");
Label1.Text = txtBxTemp.Text;
End Sub
Well those two list are C# I have no clue what VB would be maybe:
txtBxTemp as TextBox = (TextBox)e.Item.FindControl("tx") ?
|
|
|
|
|
Can anybody help to give code or application for update carrer profile page which contains
1. qualification details..(any number of rows dynamically in client side)
2. Experience details.. (any number of rows dynamically in client side)
These two this must done without using Ajax only by .net 2.0
|
|
|
|
|
svenki wrote: Can anybody help to give code or application
For free ???
Manas Bhardwaj
Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
|
|
|
|
|
Just render one HTML and place it into your div.
Mind that, you need to specify the name attribute of the dynamically created controls, as you can get the name from the Request.Params I think.
|
|
|
|
|
Public Class languagesetting
Inherits System.Web.UI.Page
Private rm As ResourceManager
Public Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
MyBase.OnLoad(e)------------>An unhandled exception of type 'System.StackOverflowException' occurred in System.Web.dll
Dim ci As CultureInfo
ci = Session("lang")
rm = New ResourceManager("Resources.Strings", System.Reflection.Assembly.Load("App_GlobalResources"))
Thread.CurrentThread.CurrentCulture = ci
LoadStrings(ci)
End Sub
|
|
|
|
|
anbusenthil wrote: Handles Me.Load
MyBase.OnLoad(e)
Don't you think, it is obvious. You are calling the Onload event from Load method. It is a recursive loop.
Manas Bhardwaj
Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
|
|
|
|
|
|
Hello,
I am using a panel control on page.
I want a html of the pannel control in codebehind.
Thanks in Advance
Regards,
Milind
|
|
|
|
|
Hi,
what are you trying to achieve? please clarify
himanshu
|
|
|
|
|
I am trying to get HTML containing in the Panel object (the panel is contaning tables and gridview)
|
|
|
|
|
milindchavan12 wrote: I want a html of the pannel control in codebehind.
You want the rendered HTML output of the panel, right? Try something like
public string GetControlRenderedOutput(Control control)
{
StringBuilder builder = new StringBuilder();
StringWriter writer = new StringWriter(builder);
HtmlTextWriter htmlWriter = new HtmlTextWriter(writer);
control.RenderControl(htmlWriter);
return builder.ToString();
} Try passing your panel's object to this method.
modified on Monday, June 15, 2009 8:42 AM
|
|
|
|
|
|
Ohh Problem ....
It is giving me error on control.RenderControl(htmlWriter) line.
public string GetControlRenderedOutput(Control control)
{
StringBuilder builder = new StringBuilder();
StringWriter writer = new StringWriter(builder);
HtmlTextWriter htmlWriter = new HtmlTextWriter(writer);
control.RenderControl(htmlWriter); return builder.ToString();
}
Error :
RegisterForEventValidation can only be called during Render();
|
|
|
|
|
Read this [^]
You are best person who knows about your problem.
-------------------------------------------------
More pain more gain
|
|
|
|
|
In my application i want to add some text and an image dynamically in a text area like we are doing in e-mail.How can it be possible.
Thanx in advance.
|
|
|
|
|
gogal1983 wrote: How can it be possible.
Its not possible in text area.
You can instead use some other element do this. for eg, a table, div etc
Manas Bhardwaj
Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
|
|
|
|
|
Email text editors are using iFrame not text area. Look at open-source implementation like tinymce[^].
|
|
|
|
|
It is not possible in a text area. You have to look for some other options where html elements can be embedded.
There is no foolish question, there is no final answer...
|
|
|
|
|
how to inherit a class file in our aspx page
to acess the functionality
|
|
|
|
|
Please read the Asp.net basics
himanshu
|
|
|
|
|
Which functionality ? TO inherit page class, use like this YourClass:Page. Do you need to add more class to be inherited. It is not possible in c#. use interface for that.
You are best person who knows about your problem.
-------------------------------------------------
More pain more gain
|
|
|
|
|
.Net does not allow multiple inheritance. As all the web forms are already inherited from a Page class, it cannot be directly done.
Another suggestion could be to create a Class(lets say BasePageClass) and inherit it from Page. Put the functionality which you currently have in your class in the BasePageClass.
Now in your aspx page, use the BasePageClass to inherit instead of Page.
Manas Bhardwaj
Please remember to rate helpful or unhelpful answers, it lets us and people reading the forums know if our answers are any good.
|
|
|
|
|
anbusenthil wrote: how to inherit a class file in our aspx page
to acess the functionality
All the question that you have asked in this forums are very basic. And it seems you don't have any idea that what you are doing. So, My suggestion to you to that please Buy some Good beginner's Book and start reading. After doing the basic from books read some article from net. Then try to do your work. It will help you in Long Run.
|
|
|
|