|
Your Welcome
|
|
|
|
|
I have a set of Sql statements which add a column to the DataBase table and also add a foreign key relationship.The statements execute fine on the sql server where as the same set of statements fail to be executed through the SQlCommand object invoke on a button click on a ASP.NET page.
Please help...below is my code
private void CreateReferenceKey(string parentTableName,string tableName,string refcolumn,string parentRefColumn)
{
StringBuilder refQuery = new StringBuilder();
refQuery.AppendLine(" if NOT EXISTS (select * from information_Schema.columns where table_name='"+tableName +"' and column_name = '"+refcolumn +"') ");
refQuery.AppendLine("BEGIN");
refQuery.AppendLine(" alter table [dbo].[" + tableName + "] add [" + refcolumn + "] smallint NULL ");
refQuery.AppendLine("ALTER TABLE [dbo].[" + tableName + "] WITH CHECK ADD CONSTRAINT [FK_" + parentTableName + "_" + tableName + "] FOREIGN KEY([" + refcolumn + "]) ");
refQuery.Append("REFERENCES [dbo].[" + parentTableName + "] (["+parentRefColumn +"])");
refQuery.AppendLine(" ALTER TABLE [dbo].[" + parentTableName + "] CHECK CONSTRAINT [FK_" + parentTableName + "_" + tableName + "]");
refQuery.AppendLine("END");
SqlCommand command = null;
SqlConnection connection = new SqlConnection(connString);
command = new SqlCommand(refQuery.ToString(), connection);
connection.Open();
command.ExecuteNonQuery();
connection.Close();
}
|
|
|
|
|
You can do the same by developing generalized SP.
Pass TableName, ColumnName and Type to add that particular
Column to the specified table.
And also do the same for adding constraint.
HTH
Jinal Desai - LIVE
Experience is mother of sage....
|
|
|
|
|
I have created fusion chart from xml in asp.net.
If i want to create child values in a fusion a chart.Suppose i want to show the students of respective class then i can use simple chart and in this chart if I want to show number of boys and girls for respective classes then how to achieve it ?
Thanks
|
|
|
|
|
Hi,
I am currently redirecting user to a different page, say ABC, using Javascript. Now if my page ABC doesnt exist, i dont want to show 404 page, but custom error page. The custom error page in web.config doesnt work here as page is being redirected from client site. See below me web.config code
<customerrors mode="On" defaultredirect="~/Error.aspx">
<error statuscode="404" redirect="~/PageNotFound.aspx">
On my Webform I have written the following code for redirection using javascript.
Javascript method
function redirectToStaticPage(language)
{
var newPageURL = "http://xyz.aspx";
try
{
window.location = newPageURL;
}
catch(err)
{
txt="There was an error on this page.\n\n";
txt+="Error description: " + err.description + "\n\n";
txt+="Click OK to continue.\n\n";
alert(txt);
}
}
Currently it takes me to http://xyz.aspx which doesnt exist. I want to show in this case custom error page.
Please help ASAP. Thanks
|
|
|
|
|
I think you need to do URL Validation at server side.
Once it is validated then you can redirect to that
particular URL.
Use following code to validate URL.
Public Class UrlValidity
Public Shared Function IsValid(ByVal Url As String) As Boolean
Dim sStream As Stream
Dim URLReq As HttpWebRequest
Dim URLRes As HttpWebResponse
Try
URLReq = WebRequest.Create(Url)
URLRes = URLReq.GetResponse()
sStream = URLRes.GetResponseStream()
Dim reader As String = New StreamReader(sStream).ReadToEnd()
Return True
Catch ex As Exception
‘Url not valid
Return False
End Try
End Function
End Class
HTH
Jinal Desai - LIVE
Experience is mother of sage....
|
|
|
|
|
hi ther,
i have a project created in asp.net 2.0. i want to calcuate how much time user spend on my site ???
i can do it by using (logout time - login time) ...but what happens if user directly close the browser by clicking [X] button...
what should i do ???
any idea...????
Thanks in advnace
koolprasad2003
Rating always..... WELCOME
Be a good listener...Because Opprtunity knoughts softly...N-Joy
|
|
|
|
|
You can handle this by using Session_Start and Session_End in Global.asax. Handle logout time at <code>Session_End</code> .This function will also be called if user close the browser by clicking [X] button, not at the same time but when it session expires.
|
|
|
|
|
|
Hi,
i need help in passing parameters from a datalist to another page.
this is how my app works:
i have a database ( access) a table with the following columns: id,title,desc,photo.
another table with the following columns: (startsin, endsin,price,tId)
on the first page (tourpack.aspx) i have a datalist, when user clicks on a button that is in the templateitem of the datalist, he will be transfered to another page called (showtour.aspx). what im trying to do is passing the ID parameter from the first page (table 1) to the second page (showtour.aspx) with the id number so he can see the specific details of that "tour" that are located In the second table.
any idea how it works? i would appreciate any kind of help.
Thanks,
Farraj.
|
|
|
|
|
Farraj wrote: passing the ID parameter from the first page (table 1) to the second page (showtour.aspx)
you need to have the a column(ID) same in both the tables. Join both the tables.
pass the ID through query string to showtour.aspx
//on page load of show tour
using the id from query string get the tour details
|
|
|
|
|
Thanks for your reply
Do you mean to join the both tables or the both ID columns? if so how do i do that?
and how can i the id from query string to get the tour details in the other page (which there i have a datagrid)?
Thanks for your help
|
|
|
|
|
On the buttonclick where you are transferring the user to another page.Pass the id in querystring as showtour.aspx?tourid=1 .
Now read this id at pageload on showtour.aspx as Request.QueryString["tourid"] and load the details for this ID.
|
|
|
|
|
thanks.
sorry for the lack of knowledge in this issue.
how can i load the details for this ID in the detailsview control i have on the second page showtour.aspx?
|
|
|
|
|
See, you need to read the ID from querystring, not get the details of the tour from DB fro this ID and show the detail using You detailsveiw control.
If you have problem is using detailsview control,the look at the following links
Link 1
Link 2
|
|
|
|
|
Hi
I have a radiobuttonlist control on my control, where the datasource is a collection, and I am using the DataTextFormatString to set the text field to a hyperlink. All this bit works, but where I am struggling to work is to add to the url path the value from the datavaluefield. Nothing I try works! Does anyone know how to set the datavaluefield into the url? Further, and one last question, my radiobuttonlist control is in a wizard step, and when the user clicks on a hyperlink, I want it to go on to the next step, all that is happening is that the link is going back to the first step. How do I correct this?
|
|
|
|
|
Hi
I have problem with my CSS where are all styles are saved to CSS file, which I link to in my master page. On my web content page, which inherits my master page, I have a number of user controls on my content page. However, the problem I have is that my tags are not applying the CSS, and I don't understand why! For example, I have a number of div tags which have display property set on them to block. Using Javascript I then change to the setting to none in order to show and hide the div tag. Adding an alert message box, and checking the div tag, the CSS property is not set then though I have applied the style via the class property of the tag. When I apply the CSS using the style proprty everything works! This is not how I want to set my CSS because my coding standard is to use the CSS file and set it via the class property. Can some explain to me why this is happening and how to fix it?
|
|
|
|
|
|
hi everybody
my problem with gridview
I create gridview like this
//...................................
<asp:gridview id="GridView1" runat="server" autogeneratecolumns="False"
="" width="108px">
<columns>
<asp:templatefield headertext="From">
<itemtemplate>
<asp:label id="Label4" runat="server" text="Account No :">
| <asp:textbox id="TxtAccNo" runat="server">
| <asp:label id="Label5" runat="server" text="Amount :">
| <asp:textbox id="TxtAccAmo" runat="server">
|
//.............................................
and in the below I have tow textbox and add button
I want when click on add button the value of the tow textbox adding/inserting
into the gridview (I want to add more than one value)
how can I make that and
thanks
|
|
|
|
|
1:Add textbox items in dataTable
2:Save dataTable in Session
3:Set GridView datasource as dataTable from Session
check this sample code
protected void Button1_Click(object sender, EventArgs e)
{
DataTable dt;
DataRow drow;
if (Session["datatable"] == null)
{
dt = new DataTable();
DataColumn dcol = new DataColumn("Column1", typeof(string));
dt.Columns.Add(dcol);
int rowcount = 0;
drow = dt.NewRow();
dt.Rows.Add(drow);
dt.Rows[rowcount][dcol] = TextBox1.Text;
Session.Add("datatable", dt);
}
else
{
dt = (DataTable)Session["datatable"];
drow = dt.NewRow();
dt.Rows.Add(drow);
dt.Rows[dt.Rows.Count-1]["Column1"] = TextBox1.Text;
Session.Add("datatable", dt);
}
GridView1.DataSource = dt;
GridView1.DataBind();
}
makhaai
modified on Thursday, June 10, 2010 5:06 PM
|
|
|
|
|
in fact I want my site admin able to create new language in his adminpanel.
is there any simple way?
thanks
mehran
|
|
|
|
|
I am not sure but, you can provide an interface where your admin user can provide the resource value and using ResourceWriter class you can achieve this.
System.Resources.ResourceWriter rw = new System.Resources.ResourceWriter("English.resources");
rw.AddResource("ResourceKey", "Value");
rw.Generate();
rw.Close();
WWW, WCF, WWF, WPF, WFC .... WTF
|
|
|
|
|
I have create a website that has a Login.aspx page, a Default.aspx page and a DoSomething.aspx page.
I have configured forms authentication in Web.config (pretty standard implementation) as follows:
<authentication mode="Forms">
<forms loginUrl="Login.aspx"
protection="All"
timeout="10"
name=".ASPXAUTH"
path="/"
requireSSL="false"
slidingExpiration="true"
defaultUrl="Login.aspx"
cookieless="UseDeviceProfile"
enableCrossAppRedirects="false" />
</authentication>
<authorization>
<deny users="?" />
</authorization>
When I run the website *without* Forms Authentication Login.aspx loads fine.
When I run the website *with* Forms Authentication Login.aspx doesn't load any images or apply any styles referenced in the css files.
Does this behavior sound familiar to anyone? What's the fix for this?
|
|
|
|
|
You should allow loading images and styles to unauthorized users, this is a typical prcactice.
By default, ASP.NET will require authorization for all files, including images. Something like:
<location path="Images">
<system.web>
<authorization>
<allow users="*"/>
</authorization>
</system.web>
</location>
<location path="css">
<system.web>
<authorization>
<allow users="*"/>
</authorization>
</system.web>
</location>
Die Energie der Welt ist konstant. Die Entropie der Welt strebt einem Maximum zu.
|
|
|
|
|
Thanks! I'll try that.
I don't think it was done that way in 1.1 was it?
|
|
|
|