|
Hi All,
I have a mysql database. I have a web portal in php where users can update personal information which is added and stored in the database. Im building another web app in asp .net which will feed from the same database.
Is there anyway of 'listening' for when updates occur in the database efficently from my asp .net web app?
Im not sure what the best approach is.
Any suggestions much appreciated.
Thanks
Mike
|
|
|
|
|
hardboy111 wrote: Is there anyway of 'listening' for when updates occur in the database efficently from my asp .net web app?
As both the site are sharing the same database then why you are trying to listing? If there is any update in the database from PHP sites, when user refresh or reload the page in ASP.NET he will get the updated data.
Any specific reason to do that?
cheers,
Abhijit
CodeProject MVP
|
|
|
|
|
hardboy111 wrote: Is there anyway of 'listening' for when updates
what do you mean by 'listening'. The very nature of web application does not allow you to listen to events on the server, or does it.
One way to try is, since they are sharing the same database, in your asp.net you may want to use AJAX to check for updated periodically. This will be small and quick bursts of status checks. When you detect a change, hen you refresh your asp.net pages to fetch updated data.
Yusuf
Oh didn't you notice, analogous to square roots, they recently introduced rectangular, circular, and diamond roots to determine the size of the corresponding shapes when given the area. Luc Pattyn[^]
|
|
|
|
|
im using a COMET approach. Hence if a update occurs I want to be able to push the update down to the web browser without any request from the client.
Polling isnt what I want to do.
|
|
|
|
|
1) does webparts use sql server 2008 database??? with visual studio 2008?
2) if i use webparts then will i have to face some browser compatibility issues??
Government Dyal Singh College Lahore.
|
|
|
|
|
Ans 1 .. No You can use any Database you want.
Ans 2. Webparts in Sharepoint runs best in IE. But you can create web parts that may run in other browsers too. Thats not a problem
|
|
|
|
|
Hi All
Please help, here us the scenario.
I get Source and Source code from the database.
I assign Source to the Text property of the DropDownlist and I assign SourceCode to the Value property of the same DropDownList.
What I want to do is that when you select an item from the DropDownlist, I want take the Value for that Item and do some calculations and keep the selected item shown on the dropDownList.
The problem is that..if the selected item has something eg 2 for the Value the application works fine, but if the Value property for that item in null the dropdown display the first item in the list.
It should display the selected item..it only do this if there is something in the value property.
Here is my code, that populates the dropdownlis.
drpDepot.DataSource = ds;
drpDepot.DataTextField = "SourceName";
drpDepot.DataValueField = "SourceCode";
drpDepot.DataBind();
drpDepot.Items.Insert(0, new ListItem(string.Empty, string.Empty));
Please help, I don’t know what is the problem. Please help.
Thank you in advanced
MP
|
|
|
|
|
khuzwayom wrote: What I want to do is that when you select an item from the DropDownlist, I want take the Value for that Item and do some calculations and keep the selected item shown on the dropDownList.
Please put the code for this section.
cheers,
Abhijit
CodeProject MVP
|
|
|
|
|
Hi
Thanx for the reply. Here is my code
_kilometers = Convert.ToDouble(txtKM.Text);
_value = drpDepot.SelectedValue.ToString().Trim();
if (_value != "")
{
_value4 = double.Parse(_value);
_transportCost = _kilometers * _value4;
lblMessage.Text = "Estimated Transport Cost is: £ " + _transportCost.ToString();
}
I suppose after finishing executing it should keep the Item selected displayed...
MP
|
|
|
|
|
khuzwayom wrote: _kilometers = Convert.ToDouble(txtKM.Text);
_value = drpDepot.SelectedValue.ToString().Trim();
if (_value != "")
{
_value4 = double.Parse(_value);
_transportCost = _kilometers * _value4;
lblMessage.Text = "Estimated Transport Cost is: £ " + _transportCost.ToString();
}
What ever you have to done in the else put.
else
{
}
But still i am not able to understand where did you written the code means in which event you are loading the data and checking the value.
cheers,
Abhijit
CodeProject MVP
|
|
|
|
|
Hi Abhijit
Thanx for the assitance.
I populate the Dropwdown in page_load
if (_value != "")
{
_value4 = double.Parse(_value);
_transportCost = _kilometers * _value4;
lblMessage.Text = "Estimated Transport Cost is: £ " + _transportCost.ToString();
}
else
{
lblMessage.Text = "The Source does not have a value"
}
If the execution got inside the if statement, it works fine, it does the calculation and keep the selected item displayed on the dropdown
but if it went ti the ELSe block, it displays the message but the dropdown displays the fisrt item which i sin index 0.
MP
|
|
|
|
|
Problem looks in Page_Load
Did you checked the ISPostBack while Loading Data on dropdown list.
if(!Page.IsPostBack)
{
}
cheers,
Abhijit
CodeProject MVP
|
|
|
|
|
Yes, I did.
I think the problem is somewhere else not postback, because if th eproblem was postback it should behave the same way even when an item something in its Value property, but it only misbahes when the item has null/nothing in its Value property.
it's C#
if (!IsPostBack)
{
BindDepots();
}
MP
|
|
|
|
|
Ya got it. . Problem is with If checking
Try this
string _value = drpDepot.SelectedValue.ToString().Trim();
if (!string.IsNullOrEmpty(_value))
{
}
else
{
}
Enjoy
cheers,
Abhijit
CodeProject MVP
|
|
|
|
|
Hi guys
Before You read this I just wanted to inform you I am using Visual Studio 2003, VB.Net as the codebehind, and running asp.net 1.1
I am currently developing an asp.net webpage where a user can input data, and then it will save that data to a Microsoft SQL Server database. The table in this database that I am saving has an ID field which I use as the primary key. The next bit of information is when the data has been inputted, and submitted it will send an email to a person which would need to view the data. This email that I want to send is a link to the data which was inputted by the user. I was wondering if it is possible to send a link to someone with the ID field of the inputted data in the URL of the link, and then have that person be able to open the link and retrieve data from the database.
Example
www.MyHours.com\timesheet\ will load up a blank timesheet for the user(Lets say his name is John) to fill out. John fills out the data, and that row in the database which has an ID of 1235, Next an email is sent out to the person(lets call this person Mary) , and she needs to view the timesheet. The URL that is sent to here www.MyHours.com\timesheet\id=1235, Then Todd fills out the data, and a new row in the database is created with an ID of 1236, and another link is sent to Mary With the url www.MyHours.com\timesheet\id=1236 which she can then click on, and view the data Todd had inputted.
If anyone knows how to do this or can just point me in the write direction on how to do this it would be greatly appreciated.
|
|
|
|
|
you can reuse the blank timesheet page to reload user data when they pass you an id. Instead of showing a blank page, query your database and load the data in the page.
Request.QueryString[^]
Ragonastick wrote: www.MyHours.com\timesheet\id=1235,
this needs to be www.myhours.com\timesheet?id=1235
Yusuf
Oh didn't you notice, analogous to square roots, they recently introduced rectangular, circular, and diamond roots to determine the size of the corresponding shapes when given the area. Luc Pattyn[^]
|
|
|
|
|
I think what you want to do is send in your email something like this:
http://myserver/myapp/MyPage.aspx?ID=68
Then in your page_load event, you could use the following to get the ID.
myParam = Request.QueryString("ID")
In the above example, it would return 68, which you could then use to perform a database lookup.
|
|
|
|
|
|
Hello Friends,
I want to have radiobutton in GridView. But only one RadioButton must be selected and also as i select a radiobutton then that row's id should be displayed
|
|
|
|
|
Use Gridview Template Field .
cheers,
Abhijit
CodeProject MVP
|
|
|
|
|
HI,
Use Templatecolumns for placing radio buttons in gridview and after that by using javascript or server side code you can hide/visble the rows ...
|
|
|
|
|
use the following code into <column> </column> tag of your gridview
<asp:TemplateField HeaderText = "Check">
<ItemTemplate>
<input id="Radio1" type="radio" name="ss" onclick="sel(this)" />
</ItemTemplate>
</asp:TemplateField>
sel() is a js function you can use code of selecting current row
<script language="javascript" type="text/javascript">
function sel(srcElement)
{
alert('Ok');
var cb = event.srcElement;
var curElement = cb;
while (curElement && !(curElement.tagName == "TR")) {
curElement = curElement.parentElement;
}
if (!(curElement == cb) && (cb.name != "cbxSelectAll")) {
if (cb.checked) {
curElement.style.backgroundColor = "gold";
rowsSelected = rowsSelected + 1;
}
else {
curElement.style.backgroundColor = "white";
rowsSelected = rowsSelected - 1;
}
}
}
</script>
|
|
|
|
|
I am filling tree view using dataset, The problem is when i click on expand or colapse control it is not working and in browser it troughs as java error has "contentplaceholder1 treeview1 data is undefined" and some stuff...Can any1 help me thanks in advance
|
|
|
|
|
i am giving one example which i did.....
i hope it will help's you.....
]]>
<title>Untitled Page
<asp:treeview id="TreeView1" runat="server" onselectednodechanged="TreeView1_SelectedNodeChanged" style="z-index: 100; left: 476px;<br mode=" hold=" /> position: absolute; top: 342px" xmlns:asp="#unknown">
<asp:dropdownlist id="DropDownList1" runat="server" autopostback="True" onselectedindexchanged="DropDownList1_SelectedIndexChanged" xmlns:asp="#unknown">
Style="z-index: 101; left: 555px; position: absolute; top: 266px">
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Data.SqlClient;
public partial class etc : System.Web.UI.Page
{
SqlConnection cn=new SqlConnection("User ID=sa; password=sa; Initial Catalog=sri; Data Source=TNLMSSRV");
string[] rolesArray;
protected void Page_Load(object sender, EventArgs e)
{
if (!Page.IsPostBack)
{
rolesArray = Roles.GetAllRoles();
DropDownList1.DataSource = rolesArray;
DropDownList1.DataBind();
}
}
protected void DropDownList1_SelectedIndexChanged(object sender, EventArgs e)
{
PopulateRootLevel();
}
private void PopulateRootLevel()
{
SqlConnection objConn = new SqlConnection("Data Source=TNLMSSRV;Initial Catalog=sri;User ID=sa;Password=sa");
//SqlCommand objCommand=new SqlCommand("select a.groupid,d.featureid,a.name,b.featurename,b.featurepath from groups a,features b,aspnet_roles c,rolesfeatures d where a.groupid=b.groupid and b.featureid = d.featureid and c.roleid = d.roleid and c.roleid = (select roleid from aspnet_usersInRoles where userid=(select userid from aspnet_users where username='sri'))order by a.sorder,3", objConn);
SqlCommand objCommand = new SqlCommand("select a.groupid, d.featureid, a.name, b.featurename, b.featurepath from groups a,features b,aspnet_roles c,rolesfeatures d where a.groupid=b.groupid and b.featureid = d.featureid and c.roleid = d.roleid and c.roleid = (select roleid from aspnet_roles where rolename='" + DropDownList1.SelectedItem + "') order by a.sorder,3", objConn);
SqlDataAdapter da = new SqlDataAdapter(objCommand);
DataTable dt = new DataTable();
da.Fill(dt);
PopulateNodes(dt, TreeView1.Nodes);
}
private void PopulateNodes(DataTable dt, TreeNodeCollection nodes)
{
TreeView1.Nodes.Clear();
foreach (DataRow dr in dt.Rows)
{
Boolean opt=false;
foreach (TreeNode tn in TreeView1.Nodes)
{
if(tn.Text == dr["name"].ToString())
{
opt=true;
TreeNode tnn = new TreeNode();
tnn.Text = dr["featurename"].ToString();
tn.ChildNodes.Add(tnn);
break;
}
}
if (opt==false )
{
TreeNode tn = new TreeNode();
tn.Text = dr["name"].ToString();
tn.Value = dr["groupid"].ToString();
nodes.Add(tn);
TreeNode tnn = new TreeNode();
tnn.Text = dr["featurename"].ToString();
tn.ChildNodes.Add(tnn);
}
}
}
protected void TreeView1_TreeNodePopulate(object sender, System.Web.UI.WebControls.TreeNodeEventArgs e)
{
PopulateSubLevel(int.Parse(e.Node.Value), e.Node);
}
private void PopulateSubLevel(int groupid, TreeNode parentNode)
{
SqlConnection objConn = new SqlConnection("Data Source=TNLMSSRV;Initial Catalog=sri;User ID=sa;Password=sa");
SqlCommand objCommand = new SqlCommand("select featurename from features where groupid=@groupid", objConn);
objCommand.Parameters.Add("@groupid", SqlDbType.Int).Value = groupid;
SqlDataAdapter da = new SqlDataAdapter(objCommand);
DataTable dt = new DataTable();
da.Fill(dt);
PopulateNodes(dt, parentNode.ChildNodes);
TreeView1.CollapseAll();
}
//private void ExpandNodes(String valuepath)
//{
//}
protected void TreeView1_SelectedNodeChanged(object sender, EventArgs e)
{
if (TreeView1.SelectedNode.Parent == null)
{
}
else
{
SqlCommand cmd = new SqlCommand("select featurepath from Features where Featurename='" + TreeView1.SelectedNode.Text + "'", cn);
if (cn.State == ConnectionState.Closed)
cn.Open();
String pp = cmd.ExecuteScalar().ToString();
cn.Close();
Response.Redirect(pp);
}
//ExpandNodes(TreeView1.SelectedNode.ValuePath);
}
}
Srikanth Reddy
|
|
|
|
|
How can I send as a response a redirection to an external link?
With asp.net I was using Response.Redirect("externalLink")
|
|
|
|