Monday, July 12, 2010

ScriptManager.RegisterStartupScript Java Script Not Working With Response.Redirect

01. Remove  Response.Redirect("~/Error.aspx");
02.Add
string redirectURL = Page.ResolveClientUrl("~/Error.aspx");
ScriptManager.RegisterStartupScript(Page, GetType(), "Script",
                                      "document.location = '" + redirectURL + "';", true);

Sunday, July 11, 2010

GridView with RadioButtonList

//In Onchange Event

Add   AutoPoseBack=true

And-----------

protected void CheckBox1_CheckedChanged(object sender, EventArgs e){
foreach (GridViewRow row in GridView1.Rows)
{
CheckBox ch = (CheckBox) row.FindControl("CheckBox1");
ch.Checked = false;
}
CheckBox checkbox = (CheckBox)sender;
checkbox.Checked = true;
GridViewRow row = (GridViewRow)checkbox.NamingContainer;
DisplayMessage(row.Cells[1].Text);
}

Wednesday, July 7, 2010

Keypress event not working C#

private void Form1_KeyPress(object sender, KeyPressEventArgs e)
{
MessageBox.Show(e.KeyChar.ToString(), "Your input");
}


IF NOT EVENT IS FIRE>>>>>>>>>>>>>>>>>>>>>
Need to set the KeyPreview Property of your Form to True so it will recognize the key press event.

Wednesday, June 30, 2010

getElementByID return always null calling from RegisterClientScriptBlock

Add  ClientScript.RegisterStartupScript instead of ClientScript.RegisterClientScriptBlock

Because>>>>>>>>>>>>>
The RegisterClientScriptBlock method inserts the client-side script immediately below the opening tag of the Page object's <form runat="server"> element. The code cannot access any of the form's elements because, at that time, the elements haven't been instantiated yet. This explains why hdnView variable had a null value in my case. The RegisterStartupScript method inserts the specified client-side script just before the closing tag of the Page object's <form runat="server"> element. The code can access any of the form's elements because, at that time, the elements have been instantiated. The choice of which method to use really depends on the "order" in which you want your script to be run by the browser when rendering the page.

Wednesday, June 23, 2010

Want to create an html link <a href=""></a> and Iframe using C# - dynamically

// Create a new HtmlAnchor control.
HtmlAnchor NewAnchorControl = new HtmlAnchor();

// Set the properties of the new HtmlAnchor control.
NewAnchorControl.Name = "NewAnchorControl";
NewAnchorControl.HRef = "http://www.microsoft.com";
NewAnchorControl.Target = "_blank";
NewAnchorControl.InnerHtml = "Microsoft Home";

// Add the new HtmlAnchor control to the Controls collection of the
// PlaceHolder control.
ControlContainer.Controls.Add(NewAnchorControl)

//Iframe
HtmlGenericControl frame1 = new HtmlGenericControl("iFrame");
frame1.Attributes.Add("runat", "server");
frame1.Attributes.Add("width", "100px");
frame1.Attributes.Add("height", "100px");
frame1.TagName = "iframe";
frame1.Attributes.Add("src", "http://www.microsoft.com");

ControlContainer.Controls.Add(frame1)

Wednesday, June 16, 2010

problem with RegisterClientScriptBlock in UpdatePanles

Error:::::
The script tag registered for type 'ASP.projectviewer_asp' and key ###### has invalid characters outside of the script tags: <link href='####.css' type='text/css' rel='stylesheet' >. Only properly formatted script tags can be registered.

This Work fine -------------
page.ClientScript.RegisterStartupScript( page.GetType(),"CSS", " <link href='####.css' type='text/css' rel='stylesheet' >", false);

Tuesday, June 15, 2010

The partner transaction manager has disabled its support for remote/network transactions

1. Go to "Administrative Tools > Services"
2. Turn on the "Distribute Transaction Coordinator" Service if it is not running
If it is running and client application is not on the same computer as
the database server, on the computer running database server
1. Go to "Administrative Tools > Component Services"
2. On the left navigation tree, go to "Component Services > Computers
> My Computer" (you may need to double click and wait as some nodes
need time to expand)
3. Right click on "My Computer", select "Properties"
4. Select "MSDTC" tab
5. Click "Security Configuration"
5 Select Network DTC Access, Allow Inbound, Allow Outbound, No Authentication Required, and Enable XA Transactions