|
In the Add event handler
TextBox txtbox = new TextBox();
txtbox.ID = some_known_id;
Page.Controls.Add(txtbox);
In the Submit event handler
use FindControl to get to your text box
TextBox txtbox = (TextBox)FindControl(some_known_id);
To make your life easier you can enumatate your text box id in a hidden control. Then on the server read the hidden control value and split the content to get to all your text box ids
|
|
|
|
|
And make sure you are creating your textboxes before page_load , otherwise It will not able to load viewstate or postback data,
|
|
|
|
|
Hi,
I need to display the 3 Lines of text in the alert Box in asp.net code behind
but '\n' is does not work. My coding is as follows
Page.RegisterClientScriptBlock("", "alert('Please Enter Date \n Please Enter Intime \n Please Enter Outtime')");
If any one know the solution Please send it immediately.
Bye.
|
|
|
|
|
Change \n to \\n. Therefore your code should be
Page.RegisterClientScriptBlock("", "<script>alert('Please Enter Date \\n Please Enter Intime \\n Please Enter Outtime')</script>");
|
|
|
|
|
Hi
Thank You so much for Your Reply.
It works well.
Bye.
|
|
|
|
|
Ramesh already answered your question
jai_101 wrote: Page.RegisterClientScriptBlock("", alert('Please Enter Date \n Please Enter Intime \n Please Enter Outtime')");
consider changing your message to
Please Enter : Date, Intime and Outtime
|
|
|
|
|
|
Panel is rendered as DIV tag in the client browser. Therefore you can print the content of a DIV tag. Check this link
|
|
|
|
|
i have to create a textbox, which is permanently available and a add
button.
the add button should create a textbox in its each click, so that 'n' number of textboxes can be created. (The created textbox should be available with a Remove Button so that the created textbox can be removed by clicking this remove button )
the target is to get the values of each textboxes created + the permanently available textbox.
i need to store the values of all these textboxes in to DB under one heading(one column name).
i need to try this out in Asp.net with C# (with the usage of Javascript to create Dynamic textboxes)
Plz help me out in getting this issue to be solved...
Ramkumar
|
|
|
|
|
No freaking home work, Plz
|
|
|
|
|
Hello Everyone,
I used this command aspnet_regsql.exe to create DB for Login Purpose now I want to use Login Control.
Could you please provide me a link to how I can use this with Login Control?
Thanks
|
|
|
|
|
|
Here is a code I use to update records, but it does not work - tough I do not get any error message.Any idea..
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data;
using System.Data.SqlClient;
namespace Haas_Login_New
{
public partial class Test : System.Web.UI.Page
{
public int sessionHUID = 5326;
public int roleid = 4;
public SqlConnection dbCon = new SqlConnection("Data Source=.........");
protected void Page_Load(object sender, EventArgs e)
{
SqlDataAdapter ad;
DataSet ds = new DataSet();
string query = "";
query = "select school, address, city, state, district from test1 where school = 'Hello'";
ad = new SqlDataAdapter(query, dbCon);
ad.Fill(ds);
if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
{
txtSchoolName.Text = Convert.ToString(ds.Tables[0].Rows[0]["school"]);
txtAddress.Text = Convert.ToString(ds.Tables[0].Rows[0]["address"]);
txtCity.Text = Convert.ToString(ds.Tables[0].Rows[0]["city"]);
txtDistrict.Text = Convert.ToString(ds.Tables[0].Rows[0]["district"]);
txtState.Text = Convert.ToString(ds.Tables[0].Rows[0]["State"]);
}
}
protected void btnSubmit_Click(object sender, EventArgs e)
{
SqlDataAdapter ad;
DataSet ds = new DataSet();
string query = "";
query = "select school from test1 where school = '" + Convert.ToString(txtSchoolName.Text) + "'";
ad = new SqlDataAdapter(query, dbCon);
ad.Fill(ds);
if (ds.Tables.Count > 0 && ds.Tables[0].Rows.Count > 0)
{
ad = new SqlDataAdapter();
query = "UPDATE test SET citystatezip = '" + Convert.ToString(txtCity.Text) + ","
+ Convert.ToString(txtState.Text) + "' WHERE school = '" + Convert.ToString(txtSchoolName.Text) + "'";
SqlCommand sql = new SqlCommand(query, dbCon);
ad.UpdateCommand = sql;
}
else
{
ad = new SqlDataAdapter();
query = "Insert INTO test1 (school, district, city, state, address) VALUES ('"
+ Convert.ToString(txtSchoolName.Text) + "','"
+ Convert.ToString(txtDistrict.Text) + "','"
+ Convert.ToString(txtCity.Text) + "','"
+ Convert.ToString(txtState.Text) + "','"
+ Convert.ToString(txtAddress.Text) + "')";
SqlCommand sql = new SqlCommand(query, dbCon);
ad.InsertCommand = sql;
}
}
}
}
|
|
|
|
|
When you click Submit button, the page load event is executed and then btnSubmit_Click will be executed. In the page load event, the textboxes are always updated from the datatable. Therefore the values that you entered in this textboxed will always be cleared during postback.
Put your code in the page load event in a if(!IsPostback) block.
|
|
|
|
|
Thank you.
That will help.
|
|
|
|
|
Hello,
I'm having problems with a website I created. The page tries to read a dbf from a folder in a computer on the network and reads the values to a dataset. I get the error Datatable could not be filled.
The thing is when I put the website on an IIS 6 test server it works fine.
I'm not sure what the problem is, I'm fairly new using IIS 7 and don't understand it very well.
Thank You
|
|
|
|
|
Generally the asp.net application will run under Network Service account in IIS 6.0. Therefore pls check whether the Network Service account has read access to the network folder where your dbf file is stored.
|
|
|
|
|
Ramesh Swaminathan wrote: Generally the asp.net application will run under Network Service account in IIS 6.0.
That is bogus. Where did you get that information from? asp.net never runs under Network Service account. It runs under ASPNET build in account. ^
|
|
|
|
|
Hi Yusuf,
Please read what i had mentioned in my reply. I said asp.net application will run under Network Service account in IIS6.0. IIS 6.0 is used in Windows 2003 and IIS 5.x is used in Windows XP. Usually the asp.net runs under aspnet account in Windows XP.
The question is related to some issue in the server not in the PC. Therefore please read again the MS Technet link carefully.
|
|
|
|
|
How do you get the System.Web.HttpContext.Current.Request.ServerVariables("HTTP_REFERER") in a web service. I need to know where the request is coming from and using the above does not work.
Thanks
|
|
|
|
|
john_paul wrote: How do you get the System.Web.HttpContext.Current.Request.ServerVariables("HTTP_REFERER")
Isn't HTTP_REFERER a HTTP Header and not a Variable?
System.Web.HttpContext.Current.Request.Headers
|
|
|
|
|
Don't bother with server variables or headers. Just use the Request.UrlReferrer[^] property directly.
|
|
|
|
|
I have a datalist having a dropdownlist control on each row. On selecting a particular item of this dropdown, I need to display a page in that particular row of the datalist. There are five different pages and the selection of the page to be displayed depends on the item selected in the drop down list.
Actually, the controls on the pages is waht i need. So instead of the pages if you have any other option do let me know.
Note : The number of rows in the datalist keeps on varying.
|
|
|
|
|
Hi guys,
I am new to ASP.net and I am trying to achieve the following:
I have created a login page where I want only 1 user logged in at any period. Is there a way to get the current # of user logged in, in ASP.Net?
Basically, when second user tries to login, I want to check if there is another user logged in. I tried using session but that doesn't work because each user is on a different computer browsing the site.
Please help!!!!
Sameer
|
|
|
|
|
Saamir wrote: I have created a login page where I want only 1 user logged in at any period
what do you meant only 1 use logged in at any time? I hope you not restricting Only ONE user to connect to your application at a time. If that is what you want, you are in the wrong place. Web app are meant to be used by multiple users at a time.
If you want to limit to a single login to each user, then you need to track who is logged in. When a user logs in then flag that in your users table. Then when the user logs out, remove the flag. Then you need to handle end of session event and remove the flag for that user. When you notice a user tries to log in multiple times, then you can redirect them to different page (may be user already logged in message)
|
|
|
|