|
use.. TextBox textboxmaster = (TextBox) Master.FindControl("TextBox ID in MasterPage");
"Don't worry if it doesn't work right. If everything did, you'd be out of a job." (Mosher's Law of Software Engineering)
|
|
|
|
|
Hi all I want to create a very generic search control which i can use it on any page.so as to search the data from the table provided by user,list of columns and the sql will be dynamically created depending on textbox id and there respective values.
Please Suggest how do i create a server control so that i can use it on any page which will be either return dynamic sql or datasource for binding with gridview.
protected void Button1_Click(object sender, EventArgs e)
{
string conn=server=localhost;database=MyData;uid=sa;password=password";
SqlConnection sconn = new SqlConnection();
sconn.ConnectionString = conn;
ArrayList ar = new ArrayList();
ArrayList ar1 = new ArrayList();
foreach (Control c in Panel1.Controls)
{
Type t = c.GetType();
string id;
string value;
string name = t.Name;
TextBox t1 = null;
if (name.Equals("TextBox"))
{
id = c.ClientID;
ar.Add(id);
t1 = (TextBox)c;
if (t1.Text.Length>0)
{
value = t1.Text;
}
else
{
value = "%";
}
ar1.Add(value);
}
}
bool lbHasWhere = false;
StringBuilder loBuffer = new StringBuilder();
loBuffer.Append("Select '"+columns+"' From '" + tablename+ "'");
for (int k = 0; k < ar.Count; k++)
{
if (lbHasWhere)
loBuffer.Append(" And ");
else
{
loBuffer.Append(" Where ");
lbHasWhere = true;
}
loBuffer.Append("" + ar[k] + " like '" + ar1[k] + "'");
}
SqlCommand scomm = new SqlCommand();
scomm.CommandText = loBuffer.ToString();
scomm.Connection = sconn;
sconn.Open();
SqlDataReader sdr = scomm.ExecuteReader();
GridView1.DataSource = sdr;
GridView1.DataBind();
sconn.Close();
}
}
|
|
|
|
|
Hi,
I have an click once application. The prerequisites which i have mentioned is .net Framework 2.0. If the prerequisite is not there, in publish.html, i get a button to download it, else the Run button will install the application (which is developed by me) . This works fine in all the machines, except for one in which i have the following versions of .NET Framework,
.NET Framework 3.0 Service Pack 2 3.2.30729
.NET Framework 3.5 SP1 3.5.30729
.NET Framework 2.0 Service Pack 2 2.2.30729
In this machine even though we have Framework 2.0 and higher versions, i am getting the button to download Framework. This is not correct. Can any one help me on how to overcome this problem.
N.Surendra Prasad
|
|
|
|
|
How to Hide WebForm in ASP.NET on Click of button.
|
|
|
|
|
That is not clear. Read the posting guidelines and rephrase your question.
|
|
|
|
|
Hi everyone,
I have a control who contains a repeater to display some Url whith some parameters below the code of the control
<ul class="chapiter">
<asp:Repeater ID="Chapiters" runat="server">
<ItemTemplate>
<%# ShowLink(DataBinder.Eval(Container.DataItem, "QuestionId"))%>
<a href="SaisiePage.aspx?onglet=2&idchapiter=<%# DataBinder.Eval(Container.DataItem, "QuestionId")%>">
<%# DataBinder.Eval(Container.DataItem, "Description")%>
</a>
</li>
</ItemTemplate>
</asp:Repeater>
</ul>
the problem that in href link i must make a POST to the page not a GET. th problem that for style reason i must keep the <li><a></a></li> to keep the style in the page.
is that possible, is there any trick to do it?
thanks you for help!
|
|
|
|
|
You could use xmlhttprequest, the same thing that you use for AJAX stuff.
|
|
|
|
|
ASALAMOALEKUM,
i am using ASP.NET WITH C# FOR my website.
I have an ONLINE table which stores the id of the user who signin to the site.
Now i want to delete the id of the user from the ONLINE table who signout by using SIGNOUT button or close my website from browser.
behind the SIGNOUT button, i have applied simple sql delete query which works properly but in case of closing browser i have tried the GLOBAL.asax event
APPLICATION_END() ... which contains the same delete query... but it doesnt workssss.. can anyone tell me why its not working ??
do we have to make any settings in webconfig filee??
but as i have put the same delete query in the Session_End() event of global.asax... after 24-25mins of closing the browser it hits and delete the id from the table... i dont want such a great delay...!
please guide if i am missing any imp point in my implementation!
thnks,
Regards,
SANA
$@N@
|
|
|
|
|
You have mis-understood what Application_End is for. It is not for when a user closes the window, but instead is fired when ASP .NET is actually shutting down the web application. You can get lower timeouts by adjusting the session timeout in web.config.
|
|
|
|
|
Sounds like your after Session End in the Global ASAX. You need to kill the session when the user hits the signout by calling Session.Abandon(). That way you don't have to wait for the timeout.
|
|
|
|
|
well this is the solution for signout button only,
my major problem is with BROWSER closing event... i have to delete user's id from ONLINE table at this event.
My website is about chatting.... thats why this user's online/offline state is very important to manage... i cant let user's status remain be online if he/she has closed the application from browser...
$@N@
|
|
|
|
|
This is asked frequently. No events are fired on the server when user closes the browser window. You can follow any of the following suggestions.
1 - Hook a JS method for the browser close event, do AJAX call which delets the record from database. This is less reliable as JS can be turned off from the client.
2 - Keep users last request time in the table. Run a SQL scheduler job which scans this table frequently and if the current time minus last active time is more than the session timeout limit, delete the record. I suggest this method as this is more reliable than the first one.
Does that help?
|
|
|
|
|
hi frndz,
i wanna ask can i change text property of a label of some other webform(.aspx) in current webform(.aspx)
with thanks
Tarun Suneja
|
|
|
|
|
You should only be displaying one webform(.aspx) at a time.
You can pass values from one to another via querystring or storing in session.
Then set the value of the next page on page load.
Don't forget
if (!ispostback)
{
}
I didn't get any requirements for the signature
|
|
|
|
|
If you don't want to use a postback you can try using javascript. Something like ...
window.parent.document.getElementById("X")
|
|
|
|
|
I'm trying to validate a date, however, somehow the same code is not working within one project whilst it is working on the "test" project.
I've also noted that although the OS regional options format is set to dd/mm/yyyy, the format returned by another control (in my case a grid view), is in the following format: 3/31/2009 12:00:00 AM. Is it possible that .NET has its own "default setting"? Information would be appreciated.
I also tried checking the other methods accepted by DateTime.Parse. It would be appreciated if you could guide me as to what they usually mean.
Specifically what options should I fill in for IFormatProvider (a dummy value?) and System.Globalization.DateTimeStyles.
I've skimmed the web high and low so far and haven't found any specific info so far.
Any idea why?
DateTime _dateToValidate;
if (DateTime.TryParse(txtIdealDeliveryDate.Text, out _dateToValidate) != true)
{
Response.Write("Invalid date format for Ideal Delivery Date. Please leave empty or update date in [dd/mm/yyyy] format");
ButtonMode = multifunctionButtonFunction.NoUpdate;
}
.NET Framework 2.0
Related links:
http://msdn.microsoft.com/en-us/library/97x6twsz(VS.80).aspx[^]
Jon
|
|
|
|
|
If I understood you correctly, you want to validate the date and allow only dd/mm/yyyy format. Correct? If yes, following code will do it
string dateString = "3/31/2009 12:00:00 AM";
string dateFormat = "dd/M/yyyy h:mm:ss tt";
DateTime dateTime;
if (!DateTime.TryParseExact(dateString,dateFormat,
CultureInfo.InvariantCulture, DateTimeStyles.None, out dateTime))
else
I am on linux now and I haven't tested the above code. But looks like it will do the job.
|
|
|
|
|
Also it easy to use an asp.net validator control.
<code>
<asp:comparevalidator id="TargetDateValidator" runat="server" type="Date" operator="DataTypeCheck" display="dynamic"
ValidationGroup="Default" ErrorMessage="The target date is not valid format = "mm/dd/yyyy" ControlToValidate="TargetDateTextBox"></asp:comparevalidator>
</code>
I didn't get any requirements for the signature
|
|
|
|
|
hi frndz,
i am working with a project and stuck sumwhere. i need sum help regarding that.
actually i have some items in one dropdownlist of a webform(.aspx page). i want the selected value to be transferred to a textbox in other webform(second .aspx page).
i'll be thankful to u if u can help me......
with thanks...
Tarun Suneja
|
|
|
|
|
You need to read about Session in ASP.Net, you can find some nice atricles on CodeProject.
anyways quick answer is:
On the First Page. at "DropDownList" : "SelectedIndexChanged" event.
store the value in the Session.
i.e.
Session["_Value"] = DropDownList1.Text
And on Second Page. at Page Load event.
get the value stored in the session.
i.e.
TextBox1.Text = (string) Session["_Value"];
|
|
|
|
|
|
Pass it as query string if the information is not secured.
|
|
|
|
|
Try this :
Respose.Redirect("~/second.aspx page?selectedValue=" + DropDownList1.SelectedValue.ToString()
|
|
|
|
|
I'm using a gridview in order to display some information from a database, and, I would like to make it obvious to the user which row they have selected.
Control: System.Web.UI.WebControls.GridView
I have set:
SelectedRowStyle > BorderColor to Black
SelectedRowStyle > BorderStyle to Dotted
Do I need to set anything else?
Jon
|
|
|
|
|
I think you've got it.
If you're just starting with data access, you may find this series of tutorials useful: http://www.asp.net/learn/data-access/[^]
Helped me no end when I started.
Frauke Nonnenmacher
Creative Cats
|
|
|
|