|
Good morning,
I've searched the web for a week to find a solution to a problem, but I can't figure it out, so now I'll try to post directly what the problem is and hope that someone could explain me how to go ahead. I'm new to Asp.Net, and some years have passed since I used to programme in C/C++.
I have an aspx page with two "Controller" textboxes.
If you insert a number X in TB1, on the OnTextChanged event, a Placeholder is populated with X TextBoxes (the number you entered).
If you insert a number H in TB2, on the OnTextChanged event, a Placeholder2 is populated with H TextBoxes (the number you entered).
The problem is that each time you enter a number you have a postback, hence after the first time, you loose all the data and the TextBox Controls in the PlaceHolder already populated. I cannot use Ajax UPdatePanel, so I know I should save the user data with the viewstate or Session, but i don't have idea of how to recall them to repopulate the PlaceHolder after Postback.
Here is my code C++C#(I tried to leave just the interesting parts).
<table>
<tr><td valign="middle"></td>
<td><asp:TextBox ID="cldtb" runat="server" OnTextChanged="cldtb_OnTextChanged" AutoPostBack="true"></asp:TextBox></td>
<td valign="middle"><asp:Panel id="pnlEnterNumbers" runat="server">
<asp:PlaceHolder id="myPlaceHolder" runat="server" /></asp:Panel> </td> </tr>
</table>
protected void cldtb_OnTextChanged(object sender, System.EventArgs e)
{
int I, intNumberCount;
intNumberCount = System.Convert.ToInt16(cldtb.Text);
if (intNumberCount > 0)
{
System.Web.UI.WebControls.TextBox txtNumber;
for (I = 1; I <= intNumberCount; I++)
{
txtNumber = new System.Web.UI.WebControls.TextBox();
txtNumber.ID = "birthdate" + I;
txtNumber.MaxLength = 8;
myPlaceHolder.Controls.Add(txtNumber);
}
ViewState["NumberCount"] = (I - 1);
}
}
modified on Monday, February 22, 2010 5:52 AM
|
|
|
|
|
smilingeyes76 wrote: Here is my code C++
This is C#, not C++. You don't even know what language you are using
smilingeyes76 wrote: (I tried to leave just the interesting parts).
Still way to much, but it does show that you have no idea what you are doing.
Why are you creating the controls dynamically in the first place?
smilingeyes76 wrote: I've searched the web for a week
Try searching for the proper way to create custom controls and supporting postback I know the language. I've read a book. - _Madmatt
|
|
|
|
|
Thank you Mark.
Yes, I made a mistake in writing, I know it is C#.
I need dynamic controls because their number depends on the value of a static control.
I solved my problem with javascript.
I'm studying tutorials, and I'm learning step by step while practicing, also thanks to experts like you, that explain newbies how to proceed...
|
|
|
|
|
Hi, I have hooked up a textbox to an autocomplete extender control and it seems to work fine with me restricting what is displayed as the user types via a web method in the code behind. I am using the CreateAutoCompleteItem key value pairs method. I have also created an OnClientItemSelected event which can update the value of a hidden field.
The problem I have is when the user might want to retrieve a record and I want the textbox to display the correct value when the page loads. If possible making my textbox have key value pairs, etc.
Can anybody please suggest a way?
Thanks
|
|
|
|
|
this is code i wrote to check check boxes in datalist control
but if i checked all checkboxes only it is returning true not for one or multiple checkboxes
help me...
foreach (DataListItem dli in DataList1.Items)
{
CheckBox Chk = (CheckBox)dli.FindControl("CheckBox1");
if (Chk.Checked)
{
str13 = "cheked";
}
else
{
str13 = "you need to check";
}
}
LblErr.Visible = true;
LblErr.Text = str13;
|
|
|
|
|
If you are talking about the value of LblErr.Text, it will always be according to the checked state of your last item in DataList1.
I am sure you can easily guess why is it so.
If you want your str13 to have "cheked" for one or multiple checkbox checked, just add a break statement just after the statement str13 = "cheked";
foreach (DataListItem dli in DataList1.Items)
{
CheckBox Chk = (CheckBox)dli.FindControl("CheckBox1");
if (Chk.Checked)
{
str13 = "cheked";
break;
}
else
{
str13 = "you need to check";
}
}
LblErr.Visible = true;
LblErr.Text = str13;
This should solve your problem.
|
|
|
|
|
thank you bro..
|
|
|
|
|
hi.
currently i m using asp.net 2.0...
i need the date format in gridview as "dd/mm/yyyy hh:mm"
Note : i dont need seconds. time should be in 24hours format
help me plzmodified on Thursday, February 18, 2010 7:27 AM
|
|
|
|
|
AFAIK there is no support for tht format so ,
convert the date time format into string and do string manipulation..!
LatestArticle :Log4Net
Why Do Some People Forget To Mark as Answer .If It Helps.
|
|
|
|
|
oh.. want to inform to MICROSOFT?
anyway, thanks for reply pal.
|
|
|
|
|
hi,
Use DataFormatString property in gridviewFarogh Haider
Web developer
|
|
|
|
|
i have applied all types of DataFormatString property in gridview. but i cant get what i expect. help me plz
|
|
|
|
|
Your format should be dd/MM/yyyy HH:mm
Check out MSDN[^] for more details on the format strings available.
|
|
|
|
|
HI,
First I am receiving following error:
Retrieving the COM class factory for component with CLSID {000209FF-0000-0000-C000-000000000046} failed due to the following error: 80040154.
now resolve it n server..
i want to view document from some server location.
1) The below code is view document from some location.its properly working in local system.
if i am going to publish this code in IIS, nothing can view document..
Dim WordApp As New Word.ApplicationClass()
Dim missing As Object = System.Reflection.Missing.Value
Dim fileName As Object = "\\XXX.XXX.X.X\d\TEST.DOC"
Dim newTemplate As Object = False
Dim docType As Object = 0
Dim isVisible As Object = True
Dim aDoc As Word.Document = WordApp.Documents.Add(fileName, newTemplate, docType, isVisible)
WordApp.Visible = True
2) The below code is converting pdf from ms word doument. this also didnt working while im phblishing code in IIS
Dim filesource As Object ="\\XXX.XXX.X.X\d\test.doc"
Dim app As New Word.Application
Dim missingValue As Object = Type.Missing
Dim ac As New Word.Application()
Dim myTrue As Object = True
Dim myFalse As Object = False
Dim document As New Word.Document
app = ac.Application
app.DisplayAlerts = Word.WdAlertLevel.wdAlertsMessageBox
document = app.Documents.Open(filesource, myTrue, missingValue, missingValue, missingValue, missingValue, missingValue, missingValue, missingValue, missingValue)
app.ActivePrinter = "PDF995"
'app.ActivePrinter = "PrimoPDF"
app.ActiveDocument.PrintOut(myFalse, myFalse, missingValue, missingValue, missingValue, missingValue, missingValue, missingValue, missingValue, missingValue, myFalse, missingValue, missingValue, missingValue, missingValue, missingValue, missingValue, missingValue)
document.Close(missingValue, missingValue, missingValue)
app.Quit(missingValue, missingValue, missingValue)
aDoc.Activate()
Please Give Solution,Yours,
KaNNaN
-----------------------------------------------------------------
"Success is When Ur Signature Becomes An Autograph"
|
|
|
|
|
It looks like you do not have Word (or the correct version of it) installed on your server. Bob
Ashfield Consultants Ltd
|
|
|
|
|
|
|
|
K2? Cheers!!
Brij
|
|
|
|
|
|
thanx Cheers!!
Brij
|
|
|
|
|
Hi,
I want to import excel data in sqlserver 2000 using asp.net 2.0
Please help me asap.
thanksFarogh Haider
Web developer
|
|
|
|
|
|
Thanks alot,
It's working fine.
can we use bulk insert.Farogh Haider
Web developer
|
|
|
|
|
Dont Forget to mark it answer if it helps..!
LatestArticle :Log4Net
Why Do Some People Forget To Mark as Answer .If It Helps.
|
|
|
|
|