Showing posts with label model. Show all posts
Showing posts with label model. Show all posts

Wednesday, March 28, 2012

why Javascript doesnt work properly in updatepanel?

i wanna my gridview to change into editrow model by click any space in the row , so i wrote in the aspx page:

.....
<script type="text/javascript">
function ClickEvent(cId)
{
var id=cId;
document.getElementById("rowid").value=id;
document.getElementById("btnBindData").click();
}
</script>
.....

<asp:LinkButton ID="btnBindData" runat="server" OnClick="btnBindData_Click" Width="0px" style="width:0px; height:0px"></asp:LinkButton>
<input type="hidden" id="rowid" runat="server" /> //send clicked row index to editindex property

<asp:GridView ID="GridView1" runat="server" AutoGenerateColumns="False" DataSourceID="SqlDataSource1"
OnRowDataBound="GridView1_RowDataBound">
<Columns>
<asp:BoundField DataField="userName" HeaderText="userName" SortExpression="userName" />
<asp:BoundField DataField="userPassword" HeaderText="userPassword" SortExpression="userPassword" />
</Columns>
</asp:GridView>

In the aspx.cs file i wrote:

.......

protected void GridView1_RowDataBound(object sender, GridViewRowEventArgs e)
{
if (e.Row.RowType == DataControlRowType.DataRow)
{

e.Row.Attributes.Add("onmouseover", "c=this.style.backgroundColor;this.style.backgroundColor='#dfe345'");

e.Row.Attributes.Add("onmouseout", "this.style.backgroundColor=c");

e.Row.Attributes["style"] = "Cursor:hand";

e.Row.Attributes.Add("OnClick", "ClickEvent('" + e.Row.RowIndex + "')");

}
}

......

protected void btnBindData_Click(object sender, EventArgs e)
{
GridView1.EditIndex=Convert.Int32(this.rowid.Value);

.....

GridView1.DataBind();
}

It works well without UpdatePanel ,but when put the GridView in the UpdatePanel ,when I click the row, the GridView got disappeared.

Replace asp:LinkButton with asp:Button. If you want you can sorround your button with a hidden div (to hide from the user). Also add UseSubmitBehavior="false" to the asp:Button.

For example:

<div style="display: none; line-height: 0pt;">
<asp:Button id="btnBindData" runat="server" OnClick="btnBindData_Click" UseSubmitBehavior="false" />
</div>

Wednesday, March 21, 2012

Write Xml/Script in Server Side

Hi,

Is there any way to write the Xml/Script other than using the XmlWriter. I mean is there any sever side object model of atlas, which I can utilize to generate these scripts. Can you guys please give an estimated time when the complete documentation is publicly available?

You can write XML Script in one of two ways:

- You can just have static XML-script directly on the ASP.NET page. The script can use ASP.NET databinding expressions, and even repeaters.

- You can use the Atlas ScriptManager control, which provides an object model to help you generate scripts from ASP.NET server controls. For a couple of examples, check out Nikhil's blog post:

http://www.nikhilk.net/AtlasScriptManager.aspx

- If you have a control or extender that needs to write script, you can register with the ScriptManager by calling RegisterControl, and implement the RenderScript method. For an example, see:

http://www.nikhilk.net/AtlasInPlaceEditSampleBehavior.aspx

Write Xml/Script in Server Side

Hi,

Is there any way to wite the Xml/Script other than the XmlWriter. I mean is there any sever side objet model of atlas which I can utilize to generate these scripts.

You could create your own custom ATLAS control implementing the RenderScript method of the IScriptControl interface. For instance the following implementation:

public void RenderScript(ScriptTextWriter writer)
{
//Outputs <control> tag
GenericScriptComponent gsc = new GenericScriptComponent(new ScriptTypeDescriptor("control", ScriptNamespace.Default));
//Outputs <behaviors> tag
gsc.ID = this.ClientID;
GenericScriptComponent draggableBehavior = new GenericScriptComponent(new ScriptTypeDescriptor("draggableListItem", ScriptNamespace.Default));
draggableBehavior.AddValueProperty("handle", this.ClientID);
gsc.AddCollectionItem("behaviors", draggableBehavior);
((IScriptObject)gsc).RenderScript(writer);
}

will output the following XML-Script:

<control id="webPart1">
<behaviors>
<draggableListItem handle="webPart1Title" />
</behaviors>
</control>

XML creation

I need to create an XML document that i can use in a "Cascading DropDownList". I need to make it for Care Make, Model, and Year. I'm not sure exactly how to set this up or anyone has already done this so i don't have to recreate the wheel but I would appreciate any help at all.

Thanks,
QWERTYtech

Here is part of the solution.

http://ajax.asp.net/ajaxtoolkit/Walkthrough/CCDWithDB.aspx

And here is the part with the XML file.

http://www.devx.com/getHelpOn/10MinuteSolution/20382

You can have the web service return the result of the XPath query depending on the one you want.


What would i do if a car was produced from say 1991 to 2005?

would i have to make an entry for each year?


Hi,

I think you need to. Personally, I'd suggest using database for such scenario.