|
I was wondering what the typical site structure is that people use for asp.net sites?
I am using C# asp.net 2.0 and have a default.aspx page which points to a master page, MasterPage.master (which contains references to images, javascript, etc).
I would like to organise sub-areas like: mysite.com/subdir/Default.aspx
So I created this above page, and reference the MasterPage.master, but when I navigate to this page (during run mode) the images and javascript are messed up since they're all being referenced from the directory above (in which the masterpage resides).
Is there an elegant way of getting around this problem? I was thinking of creating a 'sub-level' master page but this won't be ideal since then any changes to the masterpage will require double the efforts (which kind of goes against what a master page is about anyway!)
Do most asp.net sites ONLY use the root directory?
Any help much appreciated!
Gerry
asp.net newbie
|
|
|
|
|
One thing I learned when using Master Pages and wanted the Master in its own directory (which I think is a good idea) is with all the images, style sheets, .js files and such to add this around them:
<%=ResolveClientUrl("~/YourDirectory/YourStyleSheet.css") %>
<%=ResolveClientUrl("~/YourDirectory/YourImageName.jpg") %>
<%=ResolveClientUrl("~/YourDirectory/YourScriptName.js") %>
Then (of course) replace my place holders with your information (example, your header is located in images/main_images then the tag around the header image would be
<%=ResolveClientUrl("~/images/header.jpg") %>
Hope this at least gets yous tarted.
"Let's face it, the average computer user has the brain of a Spider Monkey."
Bill Gates
|
|
|
|
|
Thanks very much Psycho Coder, this seems to fix it just dandily fine!
|
|
|
|
|
Not a problem, thats what this community is for
PS: When someone gives you the solution that works you should give them a 5 vote on their answer
"Well yes, it is an Integer, but it's a metrosexual Integer. For all we know, under all that hair gel it could be a Boolean."
Tom Welch
|
|
|
|
|
Done.
What a wicked community?!
I just posted a new post (at the top)
G
|
|
|
|
|
I hosted one page and also bin directory,web.config and precompiledapp.config while deploying will get these files.i just add only two controls in that page one HTML Text box and one Asp Label Control but when i open that page i could see only the Html Text box, Label is not shown in that page.But when i check the source of this page i could see the Label and its Text.what is the problem is there anything should i host.
|
|
|
|
|
I'm upgrading a ASP1.1 program to ASP 2.0. In the original application I used eWorld's NumericBox. In the ASP2.0 I have gone to eWorld and got the latest 2.0 controls. When I run my 2.0 application on my local computer it works fine. However when I publish to my web host server it cannot find the eWorld controls. From searching and reading many posts I have to add the eWorld as a Reference and set copy local to true. However I can't figure out how to do this. I have the Visual Web Developer 2005 Express Edition and when I right click on the project I then click on Start Options and then on References. In the References window it shows Accessibility GAC 2.0.0.0. I then click Add Reference and find/select Excentrics World Controls .NET 2.0.6.2393 C:\rogram Files\Excentric ... I then press OK and would expect it to be added to the list of References just under the Accessibility entry ... however it doesn't seem to get added and subsequently I can't specify the 'copy local' option. What am I missing?
Help appreciated
gregart
|
|
|
|
|
It looks like your referencing something installed into the GAC locally. If so, this is fine for local developement, but won't work if deployed to another server where the control(dll) is not installed in the GAC on that server.
You should be able to place the DLL inside your bin folder of your .net project and have it work properly. I've not used the control(s) your speaking of, but should be similar to that of other controls and libraries.
|
|
|
|
|
Thanks ... I did have the dll in the bin folder but it doesn't find it there ... I think I need to set up a reference but as I said not sure how to do this. There is also the register line in the .aspx file - right now I have it as follows: <%@ Register Assembly="eWorld.UI" Namespace="eWorld.UI" tagprefix="ew" %> - there seems to be a src parameter but I'm not sure if this can be used to point to the bin folder - tried it but it generates different errors...
cheers
gregart
|
|
|
|
|
I downloaded the control(s) from eworld to do a little mock up for you.
Keep in mind I did not install this in the GAC, as I wanted to use just the dll from the BIN directory. You can install it however you want, I just wanted to show how to use it without it being installed in the GAC.
I made two pages, one loads the control dynamically, the other page use the register attribute and adds the control at design time. Hopefully this gets you going.
http://www.ewilburn.com/downloads/EW_example.zip
|
|
|
|
|
Hi,
Could anybody tell me how to prevent an error while entering a text with " ' " (apostrophe) into the SQL table.
Here is my code:
SqlDataSource1.InsertCommand = "INSERT INTO Ptable(pID, title, description, date) VALUES (" + pID + ",'" + TextBox1.Text + "','" + TextBox2.Text + "','" + Convert.ToString(DateTime.Today) + "')";
So, I have a problem, when I'm entering a text like "This's..." into the TextBox1.
Thank you
|
|
|
|
|
You need to double them up - use the string Replace function
Textbox1.Text.Replace("'", "''")
So that "this's" will end up as "this''s"
I sincerely hope you are validating your input Textbox.Text carefully before passing it ot the SQL statement. You might want to read Colin's article:
http://www.codeproject.com/cs/database/SqlInjectionAttacks.asp[^]
|
|
|
|
|
Thanx!!!
|
|
|
|
|
long time did not come back...
for the sql injection issue..i'd suggest to use stored procudures instead of inline sql
<< >>
|
|
|
|
|
enjoycrack wrote: for the sql injection issue..i'd suggest to use stored procudures instead of inline sql
Yes,, also for better performance.
but in case you can't use stored procedures (because you make a dynamic query) you still can use a parameterized query.
|
|
|
|
|
Hello,
I am working on one web base portal and currently requirement is like that need to send SMS to any mobile around the world.
Can anybody help me regarding this.
URL or sample code will be helpful.
Thanks & Regards,
Kumar
|
|
|
|
|
|
there are two column names in my query to extract values.
and four rows corresponding to that query.
now i want to add both the values in the two dimensional array using redim peserve keywords.
i mean at run time i am increasing the length of the array.
i know the process in one dimensioal array.
how should i do that for two D?
-- modified at 8:01 Saturday 21st July, 2007
i am using the following code
Dim datearray(0,0) As String
Dim counter As Integer = 0
While (objDR.Read)
datearray(counter,0) = objDR.Item("wef").ToString
datearray(counter,1) = objDR.Item("abc").ToString
counter += 1
ReDim Preserve datecounter(counter, 0)
ReDim Preserve datecounter(counter, 1)
End While
Sonia Gupta
Soniagupta1@yahoo.co.in
Yahoo messengerId-soniagupta1
Love is Friendship and Friendship is Love....
|
|
|
|
|
This looks rather like a VB question than an ASP.NET question, as it has nothing at all to do with web development.
It's expensive to resize arrays. As it's not possible to actually resize an array, a new array is created every time, and all the data is copied from the old array to the new array.
Use a List of arrays, or a List of custom objects, instead of a two dimensional array.
Example in C#:
public class DemoClass {
private string _wef, _abc;
public DemoClass(string wef, string abc) {
_wef = wef;
_abc = abc;
}
public string Wef { get { return _wef; } }
public string Abc { get { return _abc; } }
}
List<DemoClass> items = new List<DemoClass>;
while (objDR.Read()) {
items.Add(new DemoClass(objDR.GetString("wef"), objDR.GetString("abc")));
}
foreach (DemoClass d in list) {
doSomethingWithTheData(d.Wef, d.Abc);
}
---
single minded; short sighted; long gone;
|
|
|
|
|
Hi,friends
i hav set allow paging property to true.
Private Sub Page_Load(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Load
cmd.Connection = cn
cmd.CommandText = "select * from EMP_DETAILS"
cn.Open()
grd.DataSource = cmd.ExecuteReader
grd.DataBind()
cn.Close()
End Sub
This is the error iam getting.
The data source does not support server-side data paging.
Suggest me to handle the error.
Thank u
|
|
|
|
|
you need to bind to a datatable, not a datareader
|
|
|
|
|
Use Datatable or Dataset instead of Datareader.
SSK.
|
|
|
|
|
Hi
I am tryin to display an image which is stored in a database
i ahve a procedure which will go to the appropiate record in my database and pull the file name from it
it should then take the file name and put it into a prefixed img src tag, which should then take the appropiate file from the imagestore and display to the web page
it all seems to work fine, even when i check the html source file the tag has been filled with the valid address but it jus doesn't seem to want to render the image
Is there anythin i need to do here? here is my code
<code> Sub getimage(ByVal sender As Object, ByVal e As EventArgs)
'Create connection string to pass database, string holds login information to mySQL,
Dim connectionString As String
connectionString = "Server=localhost; u;database=ftp1;"
'Builds .net mysql connection and passes connection string into method
Dim connection As New MySqlConnection(connectionString)
'Create mySql command string for passing query or SPROC(Stored Procedure)
Dim cmdString As New MySqlCommand
'Set Command to equal mySql connection,t so can pass SQL query
cmdString.Connection = connection
'Set command string to equal SPROC
cmdString.CommandText = "sp_getImage"
'ONLY PLACE THIS IF SPROC, sets the command to a SPROC
cmdString.CommandType = CommandType.StoredProcedure
Dim literr As New LiteralControl
Dim param As MySqlParameter
Try
'Creates parameter which will be passed into procedure
param = cmdString.Parameters.Add("?p_id", MySqlDbType.Int32)
'Sets parameter type equal to input
param.Direction = ParameterDirection.Input
'Sets parameter value equal to value held in textbox
param.Value = 4
'Creates parameter to pass into SPROC
param = cmdString.Parameters.Add("?p_image", MySqlDbType.VarChar)
'Sets parameter type to output
cmdString.Parameters("?p_image").Direction = ParameterDirection.Output
connection.Open() 'Opens DB connection
cmdString.ExecuteNonQuery() 'Executes procedure and reads in OUTPUT parameter
connection.Close() 'Closes DB connection
Catch ex As Exception
literr.Text = ex.Message
MsgBox(ex.Message)
End Try
MsgBox(cmdString.Parameters("?p_image").Value)
Dim imageStore As String = cmdString.Parameters("?p_image").Value
MsgBox(imageStore)
imgHolder.ImageUrl = ("c:\test\" & imageStore)
End Sub
<asp:image runat=server ID="imgHolder" Height="282px" Width="488px" BackColor="Red" />
</code>
|
|
|
|
|
boyindie wrote: when i check the html source file the tag has been filled with the valid address but it jus doesn't seem to want to render the image
You need to set teh ImageUrl to either a relative path from where the webpage is, or else a fully qualified web-address (http://www...etc). It can't just be any folder on your hard drive.
If your page is in the root folder of your website, adn the images in a subfo9lder called "images", you could set
imgHolder.ImageUrl = ("images/" & imageStore)
Your images folder (test) needs to be within your web application.
|
|
|
|
|
my connection code is:
String strConnection;
strConnection = "server=localhost;User ID=sa;Password=sas;database=db";
SqlConnection conn = new SqlConnection(strConnection);
conn.Open();
how will i write it in any application configuration file working in windows form,and call it on every page that needs to b connected??
can any body help me??
$h@ma!|@
|
|
|
|