|
|
One of the most confusing things in ASP.NET
picture (big)[^]
[ My Blog] "Visual studio desperately needs some performance improvements. It is sometimes almost as slow as eclipse." - Rüdiger Klaehn "Real men use mspaint for writing code and notepad for designing graphics." - Anna-Jayne Metcalfe
|
|
|
|
|
in addition to michael's answers..
http://www.15seconds.com/Issue/020102.htm
http://www.c-sharpcorner.com/UploadFile/Santhi.M/ASP.NETLifeCycle11282005043446AM/ASP.NETLifeCycle.aspx
suggestion:google to these kind of topics
|
|
|
|
|
Hello friends,
I have to start one new project,
Automatic installation of mysql db in the local machine, the function is when the exe is run.The programm should automatically detect if My sql db is alreadyy installed, if not installed then the Mysql setup file will run automatically
Please let me know how to work on this project, anybody have sample code please give and help me...
Thanks
Praveen Kumar.R
|
|
|
|
|
In your program start ODBC connection to my sql server. If MySQL service is not running, it will throw exception. Catch it and initialize MySQL setup file. Are you trying to do this on ASP.NET ?
|
|
|
|
|
hi, i am using a library to allow users to upload files through the application, it was working well but when my host provider changed the domain address, i also changed my code to fit the new one but it works with some and others it gives me an error of
(Cannot find part of the path......) or (cannot find file windows/system32/...)
please help me
thanks
abdelhameed81
|
|
|
|
|
Are you using "server.mappath" to specify your directory? Without seeing your code, the best I can do is provide an example of a solution I'm using that uploads successfully. In this sample, I upload the file into an "Uploads" folder on my server:
.aspx file:
-----------------------------------------------------------
<TR>
<TD class=td7_c align=right></TD>
<TD align=left><asp:FileUpload ID="fu_File1" runat="server"/></TD>
</TR>
<TR>
<td></td>
<td align="right">
<asp:Button ID="btnUpload" runat="server" OnClick="btnUpload_Click" Text="Upload"></asp:Button>
</td>
</TR>
-----------------------------------------------------------
.cs codebehind file:
-----------------------------------------------------------
#region Click Events
protected void btnUpload_Click(object sender, EventArgs e)
{
string targetDirectory;
if (fu_File1.HasFile)
{
targetDirectory = Server.MapPath(@"Uploads/" + fu_File1.FileName);
fu_File1.SaveAs(targetDirectory);
string dir = fu_File1.PostedFile.FileName;
Response.Write(dir);
}
}
#endregion
--------------------------------------------------------------
Hope that helps.
-Goalie35
|
|
|
|
|
Hi All,
I want to validate textbox in gridview for phone number through Javascript only. How can do this
Thanks!
|
|
|
|
|
swami samarth wrote: I want to validate textbox in gridview for phone number through Javascript only. How can do this
You can add a Custom Validator which points to that textbox in the template column of GridView. then, call the javascript function from GridView.
DEMO
The following code is for Server-side ~
using System;<br />
using System.Data;<br />
using System.Configuration;<br />
using System.Collections;<br />
using System.Web;<br />
using System.Web.Security;<br />
using System.Web.UI;<br />
using System.Web.UI.WebControls;<br />
using System.Web.UI.WebControls.WebParts;<br />
using System.Web.UI.HtmlControls;<br />
using System.Collections.Generic;<br />
<br />
public partial class Default2 :System.Web.UI.Page {<br />
protected void Page_Load(object sender, EventArgs e)<br />
{ <br />
System.Collections.Generic.List<string> s = new List<string>();<br />
s.Add("Ruby");<br />
s.Add("Diamond");<br />
s.Add("Gold");<br />
GridView1.DataSource = s;<br />
GridView1.DataBind ();<br />
}<br />
<br />
}<br />
I will post the HTML code in next thread. (otherwise, i will lose the formatting here.)
Note: isValidPhoneNumber is a javascript function to check phone number. I set this code ClientValidationFunction="isValidPhoneNumber" ControlToValidate="TextBox1" in custom validator which is put in the template column of GridView. Textbox1 is a textbox which is put in the template column of GridView.
Thanks and Regards,
Michael Sync ( Blog: http://michaelsync.net)
If you want to thank me for my help, please vote my message by clicking one of numbers beside "Rate this message". Why vote? Plz Read it here. Thank you.
|
|
|
|
|
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="Default2.aspx.cs" Inherits="Default2" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" >
<head runat="server">
<title>Untitled Page</title>
<meta http-equiv="cache-control" content="no-cache">
</head>
<body>
<script language="javascript" type="text/javascript">
function isValidPhoneNumber(sender, args){
if(args.Value == "something")
args.IsValid = true;
else
args.IsValid = false;
}
</script>
<form id="form1" runat="server">
<div>
<asp:GridView ID="GridView1" runat="server" Width="249px">
<Columns>
<asp:TemplateField HeaderText="1">
<ItemTemplate>
<asp:TextBox ID="TextBox1" runat="server"></asp:TextBox>
<asp:CustomValidator ID="CustomValidator1" runat="server" ClientValidationFunction="isValidPhoneNumber"
ControlToValidate="TextBox1" ErrorMessage="CustomValidator"></asp:CustomValidator>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="2">
<ItemTemplate>
<asp:Label ID="Label1" runat="server" Text="Label"></asp:Label>
</ItemTemplate>
</asp:TemplateField>
<asp:TemplateField HeaderText="3"></asp:TemplateField>
</Columns>
</asp:GridView>
<asp:ValidationSummary ID="ValidationSummary1" runat="server" />
<asp:Button ID="Button1" runat="server" Text="Button" /></div>
</form>
</body>
</html>
Thanks and Regards,
Michael Sync ( Blog: http://michaelsync.net)
If you want to thank me for my help, please vote my message by clicking one of numbers beside "Rate this message". Why vote? Plz Read it here. Thank you.
|
|
|
|
|
Hi,
I am using the TabContainer, in which I have 6 tabpanels. On page load I want to visible only first 4 Tabpanel. and remaining two should be invisible.
How can I do this at runtime.
Thanks!
|
|
|
|
|
It will be something like this:
In the PageLoad put this,
IF(Page.IsPostback)
{
Panel1.visible = "True"
Panel2.visible = "True"
Panel3.visible = "True"
Panel4.visible = "True"
Panel5.visible = "False"
Panel6.visible = "False"
}
Else
{
}
You can also use the Select Case for this.
Hope it helps!
Illegal Operation
Making Computer Software Talk
|
|
|
|
|
how can i create a .pdf file. I have a string with a html code. I need to make a .pdf file using that code.How can i make without using third party .dll. Is it possible to make by saving as .pdf, but i try and i didt got.
Thks
|
|
|
|
|
ypki wrote: How can i make without using third party .dll
You can study the pdf file format and then learn how to write your own third party dll.
ypki wrote: Is it possible to make by saving as .pdf, but i try and i didt got.
If you create a text file, called 'world of warcraft.txt', and you change the extension to .exe. will it run ?
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
so u mean without a .dll we cant make a .pdf file ??
.txt,.xls,.doc etc all can make by saving corresponding extentions, .pdf cant..ryt??
|
|
|
|
|
ypki wrote: so u mean without a .dll we cant make a .pdf file ??
Understand PDF file structure and write your own library to do this
|
|
|
|
|
ypki wrote: .txt,.xls,.doc etc all can make by saving corresponding extentions, .pdf cant..ryt??
Wrong. To create an xls or a doc, you can interop Office, which will create the files for you, otherwise you need to write the code yourself, in a dll or otherwise. But, no file format is natively supported by .NET except for XML, in that there's an XML writer which does help ensure your tags are closed.
The fact that you think you can rename a file to .pdf and it becomes one, indicates that you really don't understand what is going on, I'd recommend you do some serious reading here, not just about pdf, but about the nature of what it is that you're doing in general.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
|
Hello,
This is starting to really bug me. If I make a call to a function from the Page_Load it does what it supposed to do, but if I make the same call from a control on the page it does not work properly.
I am trying to create a function that dynamically creates drop down lists, bound to a db, and then sets the "onchange" property so that when the user changes the selected item it posts back and executes code on the server side. Here's my code behind:
<br />
using System;<br />
using System.Data;<br />
using System.Configuration;<br />
using System.Collections;<br />
using System.Web;<br />
using System.Web.Security;<br />
using System.Web.UI;<br />
using System.Web.UI.WebControls;<br />
using System.Web.UI.WebControls.WebParts;<br />
using System.Web.UI.HtmlControls;<br />
<br />
public partial class testcode : System.Web.UI.Page<br />
{<br />
protected void Page_Load(object sender, EventArgs e)<br />
{<br />
DropDownList ddl1 = new DropDownList();<br />
ddl1.Items.Add("Item1");<br />
ddl1.Items.Add("Item2");<br />
ddl1.AutoPostBack = true;<br />
form1.Controls.Add(ddl1);<br />
ddl1.SelectedIndexChanged += new EventHandler(ddl_SelectedIndexChanged); <br />
}<br />
protected void x(object sender, EventArgs e)<br />
{<br />
DropDownList ddl2 = new DropDownList();<br />
ddl2.Items.Add("1");<br />
ddl2.Items.Add("2");<br />
ddl2.AutoPostBack = true;<br />
form1.Controls.Add(ddl2);<br />
ddl2.SelectedIndexChanged += new EventHandler(ddl_SelectedIndexChanged);<br />
}<br />
void ddl_SelectedIndexChanged(object sender, EventArgs e)<br />
{<br />
<br />
<br />
Response.Write("works");<br />
}<br />
}<br />
And my .aspx:
<br />
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="testcode.aspx.cs" Inherits="testcode" EnableViewState="true" %><br />
<br />
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><br />
<br />
<html xmlns="http://www.w3.org/1999/xhtml" ><br />
<head runat="server"><br />
<title>Untitled Page</title><br />
</head><br />
<body><br />
<form id="form1" runat="server"><br />
<asp:Button runat="server" Text="Push Me" OnClick="x" /> <br />
</form><br />
</body><br />
</html><br />
The dropdownlist that is created on page load works fine, and upon changing the selected item from this dropdownlist it is able successfully call the correct function. However, the dropdownlist created by the button is not able to call the function properly, it just causes a page reload, and the second dropdownlist created by the button dissapeasrs. Any help would be greatly appreciated!
Thanks,
Shivam.
-- modified at 2:37 Wednesday 22nd August, 2007
|
|
|
|
|
You're hitting an order of operations problem. If you add a control dynamically too late in the page lifecycle, then it's viewstate will never be restored.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Thanks for your reply Christian,
Is there a way I can work around this problem.. What would you suggest, again.. any tips would be greatly appreciated.
|
|
|
|
|
shivamray wrote: Is there a way I can work around this problem
Yes, create dropdownlist in Page_init event. Then viewstate will be maintained for this.
|
|
|
|
|
Thanks for your reply Navaneeth,
Can you please explain how to use the Page_init event to do this, also there will be multiple dynamically created dropdownlists depending on the users input, so there might be just 1 or up to 10 dropdowns, all subsequently created one after another everytime a the user casuses a "onchange" even to be fired.
To give you a better idea, here's what I am trying to do:
The user will enter a search string in a text box and hit the search button to bring back results from the db.
Two dropdownlists will be displayed after the search results are brought back, the first will display refinement options available, such as refine by price, color, size, brand etc. and the second will display the different values available for the refinement filter they have selected, for example if they selected "Refine by Brand" in the first drop down, the second list will display "Brand A", "Brand B", "Brand C" etc.
Once they select a value from the second list, an automatic post back will call the "CreateDropDownList" method to create a new row of dropdowns, again displaying the remaining choices of refinement left after they have made the first choice such as price, color, size etc.
If you can point me in the right direction with this problem I will greatly appreciate it.
Thank you,
Shivam.
|
|
|
|
|
Handle the LoadViewState event, which fires before page load, and do it there.
Christian Graus - Microsoft MVP - C++
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
how do i compile my project to create bin folder files.
Actully i want to know what are all files required for a website to get it displayed on internet...?
|
|
|
|