|
Good luck, bro.
- S
50 cups of coffee and you know it's on!
A post a day, keeps the white coats away!
|
|
|
|
|
As per I know, if comma is there in your data you must write like
"data1,data2" inside your CSV file, so that it takes it as single data.
Abhishek Sur
|
|
|
|
|
|
If you want to add a confirmation dialog after a user presses a certain button, add an onclick attribute to the button with a confirm statement
btn.Attributes.Add("onclick", "return confirm('Ey, are you sure?')");
Works fine!
|
|
|
|
|
Thanks for the response...well see the thing is that's not the only thing I'm doing in the button's click event handler. In other words, I have code written in the code behind button1_click() event handler. So having said that, can I just use this in addition to the code that is written in the code behind as well??
Also, If I were to do this, how would I do lets say some other processing when the user clicks Yes or OK. Would that code be in the same event handler or should I do that in the Page_load()?
Thanks
|
|
|
|
|
Nope, the code I provided is client side, when the user clicks the button, a confirmation message will appear. If the user confirms that message, your code-behind event handler will be triggered (in other words, the button1_click code runs) of the user does not confirm the javascript confirmation message, no postback will take place (e.g. no code will run server-side).
You can however modify the script so that you CAN run different code on the server if you want (need) to.
|
|
|
|
|
Thanks Eduard, I appreciate it!
|
|
|
|
|
|
Dude, what is your question??
|
|
|
|
|
I am using Visual Studio 2005 and SQL Server 2005+SQL Server MAnagement Studio 2005.i m using Windows Vista home.
when in "SQL Data source" i configure it ,then after selecting "NewConnection",
i select "Sql Client".
then select the Server (.).
But then in the "Database" Dropdownlist,I couldnt find any of the databases i had made SQL Server MAnagement Studio 2005.
i am new to SQL Server 2005.Please help me out...
thanx in advance
|
|
|
|
|
Hi,
I think the way you specify the server is incorrect.
If its locally available give the server name as (local)
else select the server from the drop down list.
Hope it helps
Thx,
Gayani
|
|
|
|
|
rather than dot (.) , please put IP Address or system name. it will resolve your problem.
cheers,
Abhijit
|
|
|
|
|
I am trying to simulate a web-farm environment and I need to implement a simple ad balancer layer for this(C#/ASP.NET 2.0, IIS 5.1). I am doing it via folwing architecture. Feel free to suggest any flaws that can help me resolve the problem.
I have a web-application named LoadBalancer (LB) which has lists of hosts that it needs to connect. All the hosts are running exactly same web application. So let’s say when users connects to LB, it takes him/her to a web-form on app running on Machine1. User hits a button here but let’s say that Mafchine1 becomes unavailable now, which means that LB should try connecting to application running on Machine2. This mean that I need to capture every http request in LB, see which is the device I am currently connected to , Make sure its avaialble (otherwise get the availabe machine’s URL) and then post the http request to that machine. I tried doing it in Application_PreRequestHandlerExecute event but could not figure out how to do it. Bew is the simplied code that I currently have in Gabal.asax.
My questions.
1. Can this be done?
2. My current approach can work?
3. Any code samples will be highly appreicated.
TIA
<%@ Application Language="C#" %>
<script runat="server">
void Application_Start(object sender, EventArgs e)
{
System.Collections.Generic.List<string> ListOfMachines = new System.Collections.Generic.List<string>();
int index = 0;
// Hard-coded for brevity
ListOfMachines.Add("http://Machine1/MyWebApp/");
ListOfMachines.Add("http://Machine2/MyWebApp/");
ListOfMachines.Add("http://Machine3/MyWebApp/");
Application["MachinesList"] = ListOfMachines;
Application["CurrentIndex"] = index;
}
void Application_End(object sender, EventArgs e)
{
// Code that runs on application shutdown
}
void Application_Error(object sender, EventArgs e)
{
// Code that runs when an unhandled error occurs
}
void Session_Start(object sender, EventArgs e)
{
// Code that runs when a new session is started
string NextMachineURL = GetNextAvailableMachine(); // This returns the URL from MachinesList in round-robin fashion
// *** Establish the request
System.Net.HttpWebRequest HttpReq = (System.Net.HttpWebRequest)System.Net.WebRequest.Create(NextMachineURL);
// *** Retrieve request info headers
System.Net.HttpWebResponse WebResponse = (System.Net.HttpWebResponse)HttpReq.GetResponse();
System.IO.StreamReader ResponseStream =
new System.IO.StreamReader(WebResponse.GetResponseStream(), enc);
string strHtml = ResponseStream.ReadToEnd();
System.Web.HttpContext.Current.Response.Write(strHtml);
WebResponse.Cse();
ResponseStream.Cse();
break;
}
void Session_End(object sender, EventArgs e)
{
// Code that runs when a session ends.
// Note: The Session_End event is raised only when the sessionstate mode
// is set to InProc in the Web.config file. If session mode is set to StateServer
// or SQLServer, the event is not raised.
}
</script>
|
|
|
|
|
Are you trying to implement a loda balancer ? Will it be run on your live production ?
if yes, then i am suggest rather than try to use own LB try to use any other Third party S/W LB or H/B LB. We are also using Web Farm Architecture for Deploy our web application, and we are using H/W LB.
Because, if you are going to implement LB , then it should be the S/W LB and there is a hughe chanllange to implement it.specially Maintain the client request and session created on server.
So I will suggest you to think on that.
If its your practice purpose, then you can carry on. Good Luck !!!
cheers,
Abhijit
|
|
|
|
|
This is my semester project. Thanks for your reply.
|
|
|
|
|
Hi,
is there any event who work on firefox and IE to catch the clic on the back button!!
Thanks a lot!!
|
|
|
|
|
i dont think there is any such event there.
cheers,
Abhijit
|
|
|
|
|
You can take use of
window.onbeforeunload = function () {
// stuff do do before the window is unloaded here.
}
This event will fire when a page is unloaded... means even your file is closed...
Abhishek Sur
|
|
|
|
|
Dear All,
i'm creating HTML table dynamically in ASP.NET using C#, i created that...
problem is i want to use colspan in that...
how to do that....?
help!!!
|
|
|
|
|
Assign the ColumnSpan property a value greater than 1 for the particular TableCell perhaps?
|
|
|
|
|
There is a colspan property on the HtmlTableCell object.
HtmlTableCell td = new HtmlTableCell();
td.ColSpan = 2;
Hope this helps.
|
|
|
|
|
|
Title:Developing Web Applications, Second Edition
Microsoft Press
Chapter 11: Creating Custom Web Controls
Lesson 2: Creating Composite Custom Controls
Section: Handling Events
I wanted to have a try to create mathbox control that is discussed in this section of the book, for that:
I created a mathbox2 control in a class library named "StudioLibrary".
Then I used it in the page default of the project "StudioWebSite", but when I runs and click the sum button, it will not operate.
Problem: event handling and raising
Can any one help me to solve the problem (until after clicking on the button sum then the event will be handled and raised.)
Details: My written code:
to create the control in the MathBox2.cs located at the class library solution"StudioLibrary_8707"
###
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
namespace StudioLibrary_8707
{
[DefaultProperty("Text")]
[ToolboxData("<{0}:MathBox2 runat=server></{0}:MathBox2>")]
[DefaultEvent("Click")]
public class MathBox2 : WebControl
{
TextBox txtMath = new TextBox();
Button butSum = new Button();
Label lblResult = new Label();
[DefaultValue("0")]
public string Text
{
get
{
EnsureChildControls();
return txtMath.Text;
}
set
{
EnsureChildControls();
txtMath.Text = value;
}
}
public event EventHandler Click;
protected virtual void OnClick(EventArgs e)
{
if (Click != null)
Click(this, e);
}
char[] strSep = {'\r'};
public string[] Values
{
get
{
EnsureChildControls();
return txtMath.Text.Split(strSep);
}
set
{
EnsureChildControls();
txtMath.Text = String.Join(" ", value);
}
}
public string Result
{
get
{
EnsureChildControls();
return lblResult.Text;
}
}
public void Sum()
{
EnsureChildControls();
if (txtMath.Text.Length != 0)
{
string[] arrNums;
arrNums = txtMath.Text.Split(strSep);
double dblSum = 0;
foreach (string strCount in arrNums)
{
try
{
dblSum += Convert.ToDouble(strCount);
}
catch
{
}
}
lblResult.Text = dblSum.ToString();
}
else
lblResult.Text = "0";
}
protected override void CreateChildControls()
{
txtMath.TextMode = TextBoxMode.MultiLine;
Controls.Add(txtMath);
Controls.Add(new LiteralControl("<br>"));
butSum.Text = "Sum";
Controls.Add(butSum);
Controls.Add(new LiteralControl("  Result: <b>"));
Controls.Add(lblResult);
Controls.Add(new LiteralControl("</b>"));
butSum.Click += new EventHandler(butSumClicked);
}
void butSumClicked(object sender, EventArgs e)
{
Sum();
OnClick(EventArgs.Empty);
}
protected override void RenderContents(HtmlTextWriter output)
{
EnsureChildControls();
base.RenderContents(output);
}
}
}
###
to use the built assembly:
I copied dll file in the bin folder of the website solution"StudioWebSite_8707"
and modified the web.config as the following:
###
<assemblies>
...
<add assembly="StudioLibrary_8707, Version=1.0.0.0, Culture=neutral"></add>
</assemblies>
<controls>
...
<add tagprefix="Lib" namespace="StudioLibrary_8707" assembly="StudioLibrary_8707, Version=1.0.0.0, Culture=neutral">
</add></controls>
###
to use the control in the page "default" located at the solution"StudioWebSite_8707":
###
<lib:mathbox2 id="MathBox1" runat="server" onclick="MathBox1_Click" xmlns:lib="#unknown" />
###
For more details, I can send two solutions to your e-mail address to help me solve the problem.
With thanks before of your help, Ashkian.
modified on Monday, October 27, 2008 1:20 AM
|
|
|
|
|
Are you looking for some help or anything else..
Abhishek Sur
|
|
|
|
|
Hi, thanks for your reply.
anything else? I did not get your mean?
I just want to solve the problem and I said what it is and what I am looking for.
It is interested for me to have chat with you on yahoo messenger about 11 hours later to discuss about the problem and your solution.
Can you chat with me 11 hours later?
I must solve this problem as soon as it is possible.
Thanks for your reply again, Ashkian.
|
|
|
|