|
Use controls correctly - meaning postback my page on every text change??? Are you serious? And no, I'm not using Ajax... don't wanna go into details of why.
100s textboxes - my bad - that's a typo - 10s textboxes... It's a questionnaire, each question has a prepopulated text box against it.
Thanks anyway
|
|
|
|
|
SmartSpider wrote: Use controls correctly -
You still don't seem to understand this.
Unless the AutoPostback property is true the TextChangeEvent will not fire until a postback is triggered, such clicking a button. Since you seem to not understand the processes involved in ASP.NET I would suggest you take some time to read up on the subject before proceeding with your project.
SmartSpider wrote: And no, I'm not using Ajax
Then you are limiting yourself and reducing the overall user experience, IMO
only two letters away from being an asset
|
|
|
|
|
I am trying to learn C# etc by making this code work, its a mix of examples I've found on the web. The problem is the event handler never triggers. I would also like to change the text of the button that was clicked in the event handler. In a nutshell, I want to create an array of buttons, then change attributes as the text or color of the button selected. Eventually I want to add an array of labels which correstpond to these buttons and change the text or color depending on which button is pushed. Any help is appreciated.
public partial class _Default : System.Web.UI.Page
{
static Button[] btn_arr = new Button[14];
static int btn_count;
protected void Page_Load(object sender, EventArgs e)
{
try
{
if (btn_arr[0] is Button)
{
foreach (Button button in btn_arr)
{
add_button(button);
}
}
else
{
for (int i = 0; i < 14; i++)
{
Button new_button = new Button();
new_button.ID = "btn" + Convert.ToString(i);
new_button.Text = "Button" + Convert.ToString(i);
new_button.Click += new EventHandler(btn_Click);
btn_arr[btn_count++] = new_button;
add_button(new_button);
}
}
}
catch (Exception ex)
{
lblStatus.Text += ex.Message.ToString();
}
}
protected void add_button(Button button)
{
try
{
panelLineA.Controls.Add(button);
}
catch (Exception ex)
{
lblStatus.Text += ex.Message.ToString();
}
}
// this is never triggered
void btn_Click(object sender, EventArgs e)
{
int btnIndex = Convert.ToInt32(((Button)sender).ID.Substring(3, 1));
lblStatus.Text = "Button " + btnIndex + " was pushed." + ((Button)sender).ID;
}
}
|
|
|
|
|
scjsb wrote: The problem is the event handler never triggers.
Check this out.
public partial class Default3 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
ButtonArray();
}
protected void ButtonArray()
{
try
{
for (int i = 0; i < 14; i++)
{
Button new_button = new Button();
new_button.ID = "btn" + Convert.ToString(i);
new_button.Text = "Button" + Convert.ToString(i);
new_button.Click += new EventHandler(new_button_Click);
panelLineA.Controls.Add(new_button);
}
}
catch (Exception ex)
{
lblStatus.Text += ex.Message.ToString();
}
}
void new_button_Click(object sender, EventArgs e)
{
int btnIndex = Convert.ToInt32(((Button)sender).ID.Substring(3, 1));
lblStatus.Text = "Button " + btnIndex + " was pushed." + ((Button)sender).ID;
}
}
Cheers,
Sudhanva
|
|
|
|
|
i have this table TBLImageTest
ID int
Path nvarchar(MAX)
then i upload a image to server (local). image id and path saved to database.
like:
Id = 1,
Path = C:\Documents and Settings\MyUserAccount\My Documents\Visual Studio 2005\WebSites\MyImageTest\UploadedImages\TestImage.jpg
these exact things are saved into database.
then in my allImages.aspx i have this code:
<asp:gridview id="GV1" runat="server" autogeneratecolumns="False" datasourceid="SqlDataSource1" xmlns:asp="#unknown">
<columns>
<asp:templatefield>
<itemtemplate>
<asp:image id="Image1" runat="server" imageurl="<%# Eval("Path") %>" />
</itemtemplate>
</asp:templatefield>
</columns>
</asp:gridview>
<asp:sqldatasource id="SqlDataSource1" runat="server" connectionstring="<%$ ConnectionStrings:MyImageTestConnectionString %>" xmlns:asp="#unknown">
SelectCommand="SELECT [Path] FROM [TBLImageTest]"></asp:sqldatasource>
this doesn't show any image, it doesn't give any error too.
can someone help me with this
|
|
|
|
|
make sure all images can be accessed from IIS.
but not in local.
e.g. you can put images to a directory under IIS root. like <root>\images,
please you can access it like http:\\localhost\images\someimage1.jpg.
if it show normally, then you can display it in anywhere.
please check image path, e.g. c:\images\someimage1.jpg in asp.net webpage
doesnot work.
Glad to discuss with you and best wishes.
|
|
|
|
|
Hi!
I'm trying to do a REALLY REALLY simple math here using ASP.NET...
My code is as follows :
Response.Write(CDbl(25.76) + CDbl(18.0) - CDbl(43.76))
Essentially, it's supposed to print out the answer for 25.76 + 18.0 - 43.76 = 0
Problem is, it keeps giving me - 7.105427357601E-15
What in the world am I missing? It's simple arithmetic is it not?
Hope someone could shed some light on this.
Thank you in advance!
|
|
|
|
|
Hi, just solved the issue... Instead of Cdbl (Double), I simply changed it to a Decimal - CDec...
Thanks anyway!
Ben
|
|
|
|
|
Ben Jern wrote: ASP.NET cannot do simple arithmetic
Just to clear up a misconception you have. ASP.NET is a framework for writing web applications. It never has and never will "do simple arithmetic". The .NET Framework does have a Math class for some complex mathematical functions. Simple arithmetic is built into the language (VB or C# for example).
Ben Jern wrote: Problem is, it keeps giving me - 7.105427357601E-15
What in the world am I missing?
Although you have found an answer by yourself that returns the result that you expected, do you know why? (I'm presuming you've never done a formal course in computer science or software engineering becuase this would have been answered by a 1st year class on floating point maths)
So, what happens is that a Double is represented by 64 bits of memory. Because certaiun numbers cannot accurately be represented rounding errors occur. It is like if I ask you to represent the fraction one-third in decimal digits. The best you can give me is 0.33333333333.... In fact, the series of threes is infinite in this case. If I gave you 64 digits to represent this number, eventually you'd run out of digits to represent the value, yet it still wouldn't actually represent one-third, just a close approximation of it.
In computing terms values that are powers of 2 are represented most easily and other values are less easily represented leading to situations where you end up with a close approximation. Once you start performing mathematical operations on these close approximations you may get some very slight rounding errors creeping in to the results.
The result you got was 0.000000000000000710542935760 which, as you can see, is very close to zero.
The reason you get your answer in decimal is because that datatype is designed for very precise mathematical operations where rounding errors are less acceptable. It does come with some limitations. The processing power required is greater for decimals. The range of values is smaller with decimals. Decimals take more memory to store.
|
|
|
|
|
That certainly clears up a lot of stuff! Thank you very very much...
|
|
|
|
|
HI all,
I have developed a site in ASP.NET 2.0. While accessing my site, if user opens site in two tabs in a browser and starts working simultaneously, then it leads to sharing of session data. I want to restrict user from access site in multiple tabs like most banking sites. Please provide some solution to this problem.
Thanks in advance.
|
|
|
|
|
1. create a session, Session["pagename_time"]=a value, and save the session name in a hidden field.
2. if your access the same page, you should check all session names
start with "pagename_", disable it or remove it before you create a new
session Session["pagename_time"].
3. check the Session exist to know whether user access it from another
page.
hoping this help.
Glad to discuss with you and best wishes.
|
|
|
|
|
i'm working on project creating software using asp.net and ajax , i wanted to include feature giving the user range of color to change color of text or font of text can anybody guide me hw to go about with it or any help pls...
|
|
|
|
|
oh, this is a full solution, pls google it.
Glad to discuss with you and best wishes.
|
|
|
|
|
Guys, what is the difference between Asp.net with Ajax and Ajax alone. Please explain and if there is any links that would be helpfull. Thanks
hawari
|
|
|
|
|
ahawari09 wrote: Asp.net with Ajax and Ajax alone
AJAX = Asynchronous Javascript And XML.
There is an implementation of AJAX in ASP.NET that uses the ASP.NET postback model.
AJAX as a general concept doesn't require this and really just relies on getting XML documents on the internet and manipulating them in javascript. In fact, you don't even need XML as you can get any content.
|
|
|
|
|
After publishing a website containing only one page, the folder contains a page names default.aspx.
How should I view this page on a browser? I mean what should I do to make it available from a browser to everyone?
|
|
|
|
|
Where are you in the process? Have you set up IIS yet?
|
|
|
|
|
What do you mean by setting up IIS?
|
|
|
|
|
serima nazarian asked: How should I view this page on a browser? I mean what should I do to make it available from a browser to everyone?
I'm suggesting that in order for people to view your page in a browser you have to set up IIS (Internet Information Services)
The publication process in Visual Studio just creates a viable directory structure which you can then use with IIS in order actually make it available to people and so you can see it in a browser and not have to run it through Visual Studio.
|
|
|
|
|
|
Hi
I am using .Net 3.5 .I am using trying to create a Master detail relationship using gridview with LinqDataSource control. I am using northwind database with Categories and Products table.
For every Categoryid, I want to display the corresponding Product details.
I am getting an error which is shown below.
Here is the full code:
<asp:LinqDataSource ID="categoriesLinqDataSource" runat="server"
ContextTypeName="NorthwindDataContext"
Select="new (CategoryName)"
TableName="Categories">
</asp:LinqDataSource>
<asp:LinqDataSource ID="productsLinqDataSource" runat="server"
ContextTypeName="NorthwindDataContext"
Select="new (ProductID, ProductName, CategoryID, UnitPrice,
UnitsInStock, Discontinued)"
TableName="Products"
Where="CategoryID == @CategoryID">
<WhereParameters>
<asp:Parameter Name="CategoryID" Type="Int32" />
</WhereParameters>
</asp:LinqDataSource>
<br />
<asp:GridView ID="grdcategories" runat="server" AutoGenerateColumns="False"
DataSourceID="categoriesLinqDataSource"
onrowcreated="grdcategories_RowCreated">
<Columns>
<asp:BoundField DataField="CategoryName" HeaderText="CategoryName" />
<asp:TemplateField HeaderText="Products">
<ItemTemplate>
<asp:GridView ID="grdproducts" runat="server"
AutoGenerateColumns="False"
DataKeyNames="ProductID"
DataSourceID="productsLinqDataSource">
</asp:GridView>
</ItemTemplate>
</asp:TemplateField>
</Columns>
</asp:GridView>
protected void grdcategories_RowCreated(object sender, GridViewRowEventArgs e)
{
var ctx = new NorthwindDataContext(); //Northwind.dbml class
if (e.Row.RowType == DataControlRowType.DataRow)
{
GridView innergridview = e.Row.Cells[1].FindControl("grdproducts") as GridView;
var cat = ctx.Categories.Single(c => c.CategoryName ==
grdcategories.DataKeys[e.Row.DataItemIndex].ToString());
productsLinqDataSource.WhereParameters["CategoryID"].DefaultValue = cat.CategoryID.ToString();
innergridview.DataSource = productsLinqDataSource;
}
}
error: Index was out of range. Must be non-negative and less than the size of the collection.
Parameter name: index
Could anyone pls let me know what's wrong?</pre><pre></pre><pre></pre><pre></pre><pre></pre><pre></pre><pre></pre><pre></pre><pre></pre><pre></pre><pre></pre><pre></pre><pre></pre><pre></pre><pre></pre><pre></pre><pre></pre><pre></pre><pre></pre><pre></pre><pre></pre><pre></pre><pre></pre><pre></pre><pre></pre><pre></pre><pre></pre><pre></pre><pre></pre><pre></pre><pre></pre><pre></pre><pre></pre><pre></pre><pre></pre><pre></pre><pre></pre><pre></pre><pre></pre><pre></pre><pre></pre><pre></pre><pre></pre><pre></pre><pre></pre><pre></pre><pre></pre><pre></pre><pre></pre><pre></pre><pre></pre><pre></pre><pre></pre><pre></pre><pre></pre><pre></pre><pre></pre><pre></pre><pre></pre><pre></pre><pre></pre><pre></pre><pre></pre><pre></pre><pre></pre><pre></pre><pre></pre><pre></pre><pre></pre><pre></pre><pre></pre><pre></pre><pre></pre>
|
|
|
|
|
Hi, thanks for looking
I have this site wich had cookieless sessions enabled for the session and for the forms authentication
I decided to disable cookieless sessions, but the problem now is that googles search engine has a lot of links with the sessionid embeded, i tought that just by disabling the cookieless session in the webconfig people clicking on those links would get a page not found, and since i have a custom page for the pageotfound error, weverything would be fine, but i just realizaed that cookiless sessions are still working
Whas the best way to not allow anyone to navigate my site with the session is embeded in the url??
Thanks in advance for any feedback
Alexei Rodriguez
|
|
|
|
|
Redirect the request to your error page if the requested url contains the session parameter.
This can be easily accomplished with an HttpModule in ASP.NET.
|
|
|
|
|
Hi coders,
I am working in .NET Framwork 3.5 rightnow. I am using "asp:fileupload" control to upload files on server on one of my page. but what's happening is: first I select any file through 'FileUpload' control, then when my page goes through "PostBack" event (that is when I change something else after selecting file), the <asp:fileupload xmlns:asp="#unknown"> control is reset to its null value and at submit I am not getting any file to save.
Please help me to understand if I am missing something.
Thanks,
Anand Desai
Developer
Atharva Infotech
|
|
|
|